How Thrush makes a PDF that matches the screen
· 2 min read
Anyone who has tried to turn a web page into a PDF knows the problem: on screen everything is fine, in the PDF the columns misalign, the font changes and the text wraps somewhere else. For slides that is serious, because the PDF is what goes to the committee, the class and the email. Here is how Thrush makes the PDF come out just like what you see.

Why the PDF usually comes out different
Libraries that convert HTML to PDF on the server read the HTML and CSS on their own, and most of them understand only part of modern CSS. Features slides use all the time, such as flexible columns, grids, color variables and image filters, are left out or come out wrong. The usual alternative is to run a whole browser on the server, which needs a dedicated server and a lot of memory.
The idea: the browser measures, the server draws
The exporter’s browser is already the best layout engine there is, and it is already open. So Thrush does this:
- Your browser draws each slide off screen, with the real theme and fonts.
- A routine walks through the result and records where everything is: boxes, borders, each word, each image and each hand-drawn mark.
- Those positions go to the server as a list of drawing operations.
- The server checks everything and only draws the PDF, without reading any HTML or CSS.
Since the positions come from the browser itself, there is no line wrapping or layout math on the server to get wrong.

What this guarantees
- Same as the screen: colors, fonts, columns, tables, image filters and hand-drawn marks.
- Selectable text: you can search and copy text from the PDF.
- Embedded fonts: only the characters used, so the file stays small.
- Works on regular hosting: no browser needed on the server.
- Safer: the server never interprets HTML or CSS, a common attack surface in PDF generators.
- Fast the second time: if the presentation has not changed, the ready PDF is reused.
Sizes and steps
Choose 16:9, 4:3 or A4. Slides with ::pause or ::steps get one page per step, just like Beamer, so anyone following the PDF sees the same sequence as the talk.
The library that does this work is called Jh2Pdf and was written for Thrush; it is MIT licensed. The third-party libraries it uses are listed on the licenses page.
