Mpdf: setColumns vAlign not working

Created on 15 Apr 2020  路  3Comments  路  Source: mpdf/mpdf

I found this bug

The setColumns() feature does always stack columns to match their height.
This should only be the case when the vAlign setting is set to J or JUSTIFY.

This is mPDF and PHP version and environment (server/fpm/cli etc) I am using

mPdf 8.0.5
PHP 7.2.19
Apache (both on Win + Linux)

This is a PHP code snippet I use

<?php
    $mpdf = new \Mpdf\Mpdf();

    // both not working
    // $mpdf->SetColumns(2, '');
    $mpdf->WriteHTML('<columns column-count="2" vAlign="J" column-gap="7" />');
    $mpdf->WriteHTML('Some text...');
    $mpdf->WriteHTML('Some text...');
    $mpdf->WriteHTML('Some text...');
    $mpdf->WriteHTML('Some text...');
    $mpdf->WriteHTML('Some text...');
    $mpdf->WriteHTML('Some text...');

    $mpdf->Output();

This is the output:

image

The right column should not be filled with text! It should get filled only if the left column is full - which is obviously not the case here.

Thank you in advance!

bufix help wanted rendering research needed

Most helpful comment

Thanks for providing all that information. I have a feeling this is because the keepColumns setting is not enabled: http://mpdf.github.io/reference/mpdf-variables/keepcolumns.html

Pass that through as true when you initialise the mPDF object and it should work correctly.

All 3 comments

Thanks for providing all that information. I have a feeling this is because the keepColumns setting is not enabled: http://mpdf.github.io/reference/mpdf-variables/keepcolumns.html

Pass that through as true when you initialise the mPDF object and it should work correctly.

Thx @jakejackson1 for the quick help!

This did indeed work. Would be great to add this do the docs at least. Though I don't know if that isn't more a bug than something that should be noted in the docs. It seems that the 2nd param of setColumns() has no effect at all. Setting keepColumns = true / false before the setColumns call works as expected!

Maybe the 2nd param should set this setting automatically? No idea if that could have any side-effects...

Thx again & all the best.

This is what I tried and what worked:

```php
$mpdf->setColumns(1);
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');

// results in different-height columns
$mpdf->keepColumns = true;
$mpdf->setColumns(2);
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');

// results in same-height columns
$mpdf->keepColumns = false;
$mpdf->setColumns(2);
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');
$mpdf->WriteHTML('Some text');

Was this page helpful?
0 / 5 - 0 ratings