Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numbers are not right-aligning in table #181

Open
RPort71 opened this issue Jan 18, 2024 · 2 comments
Open

Numbers are not right-aligning in table #181

RPort71 opened this issue Jan 18, 2024 · 2 comments

Comments

@RPort71
Copy link

RPort71 commented Jan 18, 2024

I have built many PDFs using Cezpdf, but I'm stuck on this one issue now.

My code is as follows:

$columnWidth = 40;
                $vatHeadersConfiguration = [];
                if( !$isIECompany ){
                    $vatHeadersConfiguration['vat_rate'] = ['justification' => 'right', 'width' => $columnWidth];
                }
                $vatHeadersConfiguration['vat_amount'] = ['justification' => 'right', 'width' => $columnWidth];

$cols = [
                    'desc' => ['justification' => 'left', 'width' => 290],
                    'qty'  => ['justification' => 'center', 'width' => $columnWidth],
                    'each' => ['justification' => 'right', 'width' => $columnWidth],
            ];
            if (!$isIECompany || !$sharedCharges) {
                $cols['tot'] = ['justification' => 'right', 'width' => $columnWidth];
            }

$columns = [
                    'cols' => array_merge($cols, $vatHeadersConfiguration)
            ];

            $pdfobj->ezTable($invoiceData,
                $tableHeaders,
                '',
                [
                    'lineCol'   => [0.8, 0.8, 0.8],
                    'width'     => 530,
                    'shaded'    => 0,
                    $columns
                ]
            );`

When I test the PDF, I get this:
image

I don't understand why the numbers are not right-aligned. I tried changing
array_merge($cols, $vatHeadersConfiguration)
to
$cols + $vatHeadersConfiguration
but it didn't make a difference.

Any help would be much appreciated. Thank you.

@ole1986
Copy link
Collaborator

ole1986 commented Jan 18, 2024

$pdfobj->ezTable($invoiceData, $tableHeaders, '', [ 'lineCol' => [0.8, 0.8, 0.8], 'width' => 530, 'shaded' => 0, $columns ] );

Should be

$pdfobj->ezTable($invoiceData,
$tableHeaders,
'',
[
'lineCol' => [0.8, 0.8, 0.8],
'width' => 530,
'shaded' => 0,
'cols' => $columns
]
);`

@RPort71
Copy link
Author

RPort71 commented Jan 19, 2024

Thank you for the reply.
I tried that and the numbers are still being left aligned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants