Columns measured from their cells

A table whose columns were handed equal shares of the width is recognisable at a glance, and not in a good way: the references and the figures sit in three times the room they need while the descriptions wrap for want of it. The obvious cure is to write the widths in by hand, and it lasts until the day a part number gets longer.

The same list is set twice on this page. In the second, the reference, the quantity and the price are each exactly as wide as their own longest entry, and the description takes everything they leave — so the descriptions stop wrapping and nothing sits in three times the room it needs. The measuring is done in the very font the cells are drawn in, which is why the fit is right rather than nearly right, and it stays right the day a part number grows two characters.

What this example shows

  • Column widths taken from the widest cell each column holds.
  • One column left free, absorbing whatever the measured ones leave.
  • Equal shares and measured widths compared on one page.

The source code, complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library. The third is the description itself: a plain list of what the page has to say, which is what the service is sent.

Read the Rust source Read the Python source Read the JSON source

The document itself

Open the document in English Open the document in French

Columns measured from their cells, first page

Optimised, this document weighs 14.1 kB — at least 85 % lighter than most PDF generators would write it

The document is lighter than it was, and every page still looks exactly the same. See this document's row in the table of every example.

Examples near this one

A multi-page invoice table

Twelve invoice lines is one page and thirty is two, the second taking up the first's header and layout.

A self-paginating table

A long table handed over whole, deciding for itself where the pages break: its heading on top of every page, its footnote under every page, its grey grounds stated once for the whole table, and a note you draw under each page at the exact place the table reports.

Cells merged down the rows

A specification sheet whose cells are merged down the rows: each group named once beside all of its rows, with one note beside them; the thin lines stop at those cells' edges, and a note too long for the rows it covers makes them grow.

Pictures inside table cells

A catalogue whose first column is a picture rather than text: four pictures of very different sizes and proportions, each fitted whole and undistorted into the cell the table gives it and standing against a different corner of it, claiming no width from its column and no height from its row.

Every example, by subject