Pictures inside table cells

A product catalogue means photographs, and photographs come from suppliers: one is nine hundred pixels across, the next is sixteen, and no two share the same proportions. Bringing them all to a common size before the page can be laid out is a step somebody has to run, remember to run again next quarter, and account for the day it was skipped.

So the pictures go in as they came. Each is fitted, whole and undistorted, into whatever rectangle it ends up with, and where it sits inside that rectangle is the alignment the cell already had. The column keeps the width the table gave it and every row is as tall as its own text, whichever photographs arrived this morning.

What this example shows

  • Images fitted into cells without stretching or cropping them.
  • A picture that leaves the column its width and the row its height.
  • Its place inside the cell is taken from the cell's own alignment.

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

Pictures inside table cells, first page

Optimised, this document weighs 75.1 kB — at least 55 % 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.

Columns measured from their cells

One parts list twice: four columns sharing the width equally, then the reference, the quantity and the price each as wide as their own widest cell and the description given everything they leave.

Every example, by subject