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 full justification #175

Open
savioret opened this issue May 6, 2023 · 1 comment
Open

Incorrect full justification #175

savioret opened this issue May 6, 2023 · 1 comment

Comments

@savioret
Copy link

savioret commented May 6, 2023

image

In commit 00db904 the condition to call adjustWrapText was removed.
It should be put back.
NOTE: Possible duplicate of #152

This is the condition that was removed:

     if (($justification == 'full' && ($orgWidth / 100 * 90) < ($orgWidth - $width)) || $justification != 'full') {
         $this->adjustWrapText($parsedText, $orgWidth - $width, $orgWidth, $x, $wordSpaceAdjust, $justification);
     }

Example to reproduce same as provided image snapshots:

        $pdf = new \Cezpdf('a4', 'portrait');
        $pdf->ez['fontSize'] = 10;
        $pdf->rectangle(
            $pdf->ez['leftMargin'], $pdf->ez['topMargin'], 
            $pdf->ez['pageWidth'] - $pdf->ez['leftMargin'] - $pdf->ez['rightMargin'],
            $pdf->ez['pageHeight'] - $pdf->ez['topMargin'] - $pdf->ez['bottomMargin']);

        $pdf->ezText("This text is OUTSIDE a table", 0, ['justification' => 'full']);
        $pdf->ezText("This is text to show how full justification behaves in a paragraph. The expected behavior is that the first and the last lines are not fully aligned. This is text to show how full justification behaves in a paragraph. The expected behavior is that the first and the last lines are not fully aligned.", 0, ['justification' => 'full']);

        $pdf->ezText("\nThis text is INSIDE a table with no padding at all", 0, ['justification' => 'full']);
        $data = [["This is text to show how full justification behaves in a paragraph. The expected behavior is that the first and the last lines are not fully aligned. This is text to show how full justification behaves in a paragraph. The expected behavior is that the first and the last lines are not fully aligned."]];
        $pdf->ezTable(
                $data,
                '',
                '',
                [
                    'width' => $pdf->ez['pageWidth'] - $pdf->ez['leftMargin']-$pdf->ez['rightMargin'],
                    'rowGap' => 0,
                    'colGap' => 0,
                    'showHeadings'=>0,
                    'cols' => [['justification'=>'full']]]
            );

        $pdf->ezText("\nWe expect both texts to look the same", 0, ['justification' => 'full']);

Putting the condition back seems to fix the problem. I've been doing more testing and seems no collateral problems arise.
image

Thanks for your help !

savioret added a commit to savioret/ex-pdf-php that referenced this issue May 13, 2023
savioret added a commit to savioret/ex-pdf-php that referenced this issue May 13, 2023
@savioret savioret mentioned this issue May 13, 2023
@savioret savioret changed the title Incorrect full justification in tables Incorrect full justification Jul 2, 2023
@savioret
Copy link
Author

savioret commented Jul 2, 2023

This also happens just using ezText when text is fully justified and when the text contains breaklines. This is also fixed in PR #177 :

image

This code reproduces the problem:

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


$pdf->ezColumnsStart(['num' => 2, 'gap'=>20]);
$options = ['justification' => 'full'];

// Testing break lines should be considered as last lines
$text1 = "\nLorem ipsum dolor sit amet, vitae et sit posuere metus urna et vitae dolor consectetur adipiscing tristique nec odio id euismod."
."\nCurabitur euismod ex volutpat bibendum eleifend."
."\nDonec pretium pretium nibh."
."\nAt consectetur turpis porta et.\n";
$pdf->ezText($text1, 0, $options);
$pdf->ezColumnsStop();
$pdf->ezStream();

savioret added a commit to savioret/ex-pdf-php that referenced this issue Jul 2, 2023
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