From d7fa7d1b93205ddb7106110cb01409f973dde90c Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Sun, 26 Apr 2026 15:16:47 -0400 Subject: [PATCH] feat: tighter PDF margins + shorter QR caption MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wkhtmltopdf default top margin is ~25mm — leaves a half-page of empty space above the provenance header on every PDF. Set explicit 12mm top/bottom and 15mm left/right via pandoc -V margin-* options. Shorten QR caption from 'Scan to visit the living source' (six words, wrapped onto four lines in the 160px cell) to 'Scan for living source' (four words). Widen the QR cell from 160px to 200px so the caption sits on one or two lines without crowding the QR. --- remarkbox/lib/pandoc.py | 13 +++++++++++-- remarkbox/lib/provenance.py | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/remarkbox/lib/pandoc.py b/remarkbox/lib/pandoc.py index fe22b3f..0cb94cc 100644 --- a/remarkbox/lib/pandoc.py +++ b/remarkbox/lib/pandoc.py @@ -216,9 +216,18 @@ def convert(source, from_format="markdown", to_format="html5", title=None, stand else: cmd.extend(["--metadata", "title={}".format(title)]) - # PDF needs explicit engine since no pdflatex. + # PDF needs explicit engine since no pdflatex. Tighten margins — + # wkhtmltopdf defaults to ~25mm top which leaves a half-page of empty + # space above content. 12mm/15mm is enough to look printed without + # wasting paper. if to_format == "pdf": - cmd.extend(["--pdf-engine=wkhtmltopdf"]) + cmd.extend([ + "--pdf-engine=wkhtmltopdf", + "-V", "margin-top=12mm", + "-V", "margin-bottom=12mm", + "-V", "margin-left=15mm", + "-V", "margin-right=15mm", + ]) if is_binary: # Binary formats need file output. diff --git a/remarkbox/lib/provenance.py b/remarkbox/lib/provenance.py index 952328f..aa9e1e6 100644 --- a/remarkbox/lib/provenance.py +++ b/remarkbox/lib/provenance.py @@ -120,8 +120,8 @@ def header_md(canonical_uri, snapshot_iso=None, version="dev", '\n\n' '{text}\n\n' '\n' - '\n\n' - '![Scan to visit the living source]({qr})\n\n' + '\n\n' + '![Scan for living source]({qr})\n\n' '\n' '\n' '\n'