Coloured cell borders and fills

Colour in a table is how a reader is told where to look: the overdue line in red, the agreed total boxed in the company's green, a warning row that has to be seen from across a desk. It only works if the colour lands exactly where it is meant to and nowhere else — and in a grid, every line a cell has is shared with the neighbour on the other side of it.

Two things easy to confuse are kept apart here: the border a cell paints and the background it paints. The fill is the colour behind the text; the border is the lines around it. Setting one never changes the other, and a cell may carry either, both or neither.

What this example shows

  • Four sides of one cell, each in its own colour and thickness.
  • A background fill kept distinct from the border around it.
  • Every line on the page drawn by a cell, not by the grid.

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

Coloured cell borders and fills, first page

Optimised, this document weighs 10.9 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.

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.

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