You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lay out an element in CSS columns with column-count, column-width and columns #612
Part of #552 (step 28, missing support, medium priority).
CSS multi-column layout on an element is ignored: column-count, column-width, columns, column-gap, column-rule, column-span and column-fill. mPDF has columns only through its own <columns> tag, which takes column-count and column-gap as attributes. Newsletters, two-column terms and conditions, and index pages written with CSS columns come out as one column.
Measured on gravitypdf at 60b82630, PHP 8.5.4, from the positions text is drawn at.
Document
Browser
mPDF
<div style="column-count:2;column-gap:10mm"> with 80 words
Nothing reads the column-* properties from CSS. Columns::open() reads the tag's attributes (src/Tag/Columns.php:34-58) and calls SetColumns() (src/Mpdf.php:25359).
Before starting, <columns> closes every open block (src/Tag/Columns.php:36-40). mPDF's columns span the page's text area and cannot sit inside a block with its own margins, borders or background.
Fix.
A top-level block. When a block at the top level has column-count or column-width other than auto, run its content through the <columns> path:
Start columns when the block opens, with the count from column-count, or from column-width and the available width. columns sets both.
Use column-gap for the gap. normal is 1em.
Go back to one column when the block closes.
column-span: all on a child ends the columns before it, lays it out full width, and starts them again after it. <columns> already supports this, by closing and reopening columns.
column-fill.balance, the default, is what <columns>' valign="J" does. auto fills one column after another.
column-rule. Draw a vertical line between columns, the full height of the columns on each page.
Nested blocks. Columns inside a block with its own margins, borders or background need SetColumns() to work within a block's inner width, and the block's box to be painted across all columns. That is a larger change. Leave such a block in one column, and say so in the PR.
Tests. Each row above, columns with only a width, column-span: all on a heading, a columned block that crosses a page, a columned block inside a bordered block (one column, unchanged), and <columns> output unchanged.
Activity