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

Incorrect column width calculation in ezTable #179

Open
savioret opened this issue Jul 2, 2023 · 0 comments
Open

Incorrect column width calculation in ezTable #179

savioret opened this issue Jul 2, 2023 · 0 comments

Comments

@savioret
Copy link

savioret commented Jul 2, 2023

In some situations the calculation of the automatic column width assignment based on the widest column is not correct.
This can also, in some cases, lead into an infinite loop when the incorrect calculated width of the columns are too small.

image

This code shows the problem:

$pdf = new CezPDF('a4');
$pdf->selectFont('Helvetica');

$myoptions = array(
    'width' => $pdf->ez['pageWidth'] - $pdf->ez['rightMargin'] - $pdf->ez['leftMargin'],
    'showHeadings' => 0,
);

$text = str_repeat("lorem ipsum ", 7);
$data = [[$text, $text, $text]];
$pdf->ezTable($data, null, "", $myoptions);

$pdf->ezText("\n");

$text = str_repeat("lorem ipsum ", 8);
$data = [[$text, $text, $text]];
$pdf->ezTable($data, null, "", $myoptions);

$pdf->ezStream();

In this other example we get into an infinite loop:

$pdf = new CezPDF('a4');
$pdf->selectFont('Helvetica');

$myoptions = array(
    'width' => $pdf->ez['pageWidth'] - $pdf->ez['rightMargin'] - $pdf->ez['leftMargin'],
    'showHeadings' => 0,
);
$enum = "One as dasd asd asdas dsa asd saas asdasdasda One as dasd asd asdas dsa asd saas asdasdasda Three"; 

$data = [[$enum, $enum, $enum, $enum]];

$pdf->ezTable($data, null, "", $myoptions);
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

1 participant