Skip to content

Incorrect full justification #175

@savioret

Description

@savioret

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions