Advanced PDF Generation

ThiefMD tries to use the best HTML to PDF generator possible based on your content.

ThiefMD uses:

When WeasyPrint or Paged.js generates the PDF, the @page CSS property can be used1.

@page CSS

When using a @page CSS compatible PDF generator, ThiefMD will insert:

@page {
  margin: 1in 1in 1in 1in;
  size: Letter;

The paper size and margins come from the values set in the Preferences.

This comes before the Export CSS, so the values can be overwritten by the Export CSS. This can create beautiful PDF’s for screen instead of print.

Please note: The @page size should never be overwritten by the Export CSS package.

A Sample Resume or Newsletter Style

An online resume for download might have backgrounds running to the page edge.

Changing Margins

We can overwrite the margins with:

@page {
  margin: 0;

This allows us to control the padding and margins in the rest of our stylesheet.

Styling Headings

Two-Column Lists


Installing Paged.js

With flatpak, ThiefMD only has access to the user’s /home/ directory.

To pickup Paged.js, configure npm to install to the user’s home directory.

Once npm is configure, install Paged.js with:

npm install -g pagedjs-cli pagedjs

  1. WeasyPrint does not run JavaScript. Paged.js can run JavaScript, but may not calculate image height properly. WebKitGTK with Gtk2Pdf cannot maintain links in the final PDF. ThiefMD prioritizes WeasyPrint, Paged.js, then WebKitGTK with Gtk2Pdf after scanning content. Math or Syntax Highlighting will prevent ThiefMD from using WeasyPrint. Images will prevent Paged.js.