<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: RedesignPDF</title>
    <description>The latest articles on DEV Community by RedesignPDF (@redesignpdf).</description>
    <link>https://dev.to/redesignpdf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4282871%2Fdf3933da-e0f8-48eb-abf2-c3d9574754b5.png</url>
      <title>DEV Community: RedesignPDF</title>
      <link>https://dev.to/redesignpdf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/redesignpdf"/>
    <language>en</language>
    <item>
      <title>Your PDF Is a 1993 Printer Script Wearing a Trench Coat (4 Fixes, With Code)</title>
      <dc:creator>RedesignPDF</dc:creator>
      <pubDate>Sun, 06 Dec 2026 14:00:01 +0000</pubDate>
      <link>https://dev.to/redesignpdf/your-pdf-is-a-1993-printer-script-wearing-a-trench-coat-4-fixes-with-code-31dd</link>
      <guid>https://dev.to/redesignpdf/your-pdf-is-a-1993-printer-script-wearing-a-trench-coat-4-fixes-with-code-31dd</guid>
      <description>&lt;p&gt;Last Friday at 4:52 PM, a Slack message arrived with the confidence of a man who has never opened a PDF in his life:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Hey, tiny favor before the weekend? Can you make this questionnaire look presentable for the client on Monday?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The file was &lt;code&gt;questionnaire_final_FINAL_v3.pdf&lt;/code&gt;. Twenty-six pages, exported from Word, printed, signed, scanned back at 200 DPI and emailed. Somewhere in that journey a table of contents became a table of regret.&lt;/p&gt;

&lt;p&gt;Spoiler: not a tiny favor. Two evenings, one of them a Saturday.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgq6zioalrhq0jmhf17ft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgq6zioalrhq0jmhf17ft.png" alt="Quick 5-min favor before Friday 5pm" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have now spent an embarrassing amount of time learning how these files actually work, and I want to save you that time. Below: why PDFs behave like they hate you, the four traps I fell into, and the exact code I keep in a folder called &lt;code&gt;pdf-hell&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Everything here runs on my laptop, and the numbers are measured.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, why editing a PDF feels like defusing a bomb
&lt;/h2&gt;

&lt;p&gt;Because a PDF is not a document. It is a printer instruction script from 1993, wearing a trench coat and claiming to be a document.&lt;/p&gt;

&lt;p&gt;Word, Google Docs and HTML think in flows. You type a sentence, the paragraph grows, everything below it moves down. A PDF has no concept of "below". It has a canvas, and things painted on that canvas at absolute coordinates.&lt;/p&gt;

&lt;p&gt;Open any PDF in a text editor and the useful part looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BT
  /F1 11 Tf
  1 0 0 -1 72 720 Tm
  (Total Due: 14,800 USD) Tj
ET
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read it as instructions to a literal intern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;BT&lt;/code&gt; / &lt;code&gt;ET&lt;/code&gt;: begin and end a text object.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/F1 11 Tf&lt;/code&gt;: use font F1 at 11 points.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;1 0 0 -1 72 720 Tm&lt;/code&gt;: set the text matrix. That &lt;code&gt;-1&lt;/code&gt; flips the Y axis, because PDF measures from the bottom-left corner while everything else in your life measures from the top-left. The &lt;code&gt;72 720&lt;/code&gt; is the pen position in points.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;(Total Due: 14,800 USD) Tj&lt;/code&gt;: paint these characters at that spot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now delete the number. The characters disappear. Nothing else moves, because there is no "else". There is no paragraph, no line height, no flow. There is a hole where the number was, and the rest of the page is still exactly where the printer put it in 1993.&lt;/p&gt;

&lt;p&gt;That explains most of "why does this PDF editor suck".&lt;/p&gt;

&lt;h3&gt;
  
  
  The part nobody tells you: the text is usually compressed
&lt;/h3&gt;

&lt;p&gt;Those instructions are stored in a content stream, and content streams are zlib-compressed with &lt;code&gt;/Filter /FlateDecode&lt;/code&gt;. So you cannot just read the file.&lt;/p&gt;

&lt;p&gt;Two ways in. The clean one, if you have qpdf:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install qpdf
qpdf --qdf --object-streams=disable invoice.pdf invoice.qdf.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--qdf&lt;/code&gt; rewrites the file in readable form and &lt;code&gt;--object-streams=disable&lt;/code&gt; unpacks the object streams, so any editor will show you the operators. The result is bigger. That is the point.&lt;/p&gt;

&lt;p&gt;The no-install way, which is what I actually ran while writing this, on a 39 KB PDF I had just generated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;zlib&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"report.pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finditer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rb&lt;/span&gt;&lt;span class="s2"&gt;"stream\r?\n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;"endstream"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;dec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;zlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decompress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;zlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;"BT"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"latin-1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real output from that run, trimmed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BT 0 Tr/f0 24 Tf 1 0 0 -1 0 0 Tm[(\000\001\000\002\000\003\000\004 ...)]TJ
ET
Q
EMC/Span&amp;lt;&amp;gt;BDC
q 1 0 0 -1 45.354332 736.50415 cm/c0 cs 0.43137255 scn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;1 0 0 -1&lt;/code&gt; again: the flip matrix, now with a translation. That is the renderer converting from a top-left layout engine to PDF's bottom-left coordinate space.&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;(\000\001\000\002\000\003 ...)&lt;/code&gt;: those are not letters. They are glyph indices into a subset font. The letter "Q" is glyph 1 in this particular embedded subset, so it is stored as byte &lt;code&gt;\001&lt;/code&gt;. This is why copying text out of some PDFs gives you &lt;code&gt;□ □ □&lt;/code&gt;, and why "just extract the text" is a harder problem than it sounds. The file does not contain the string "Q4 Platform Release Notes" anywhere. It contains a sequence of numbers that a specific embedded font knows how to draw.&lt;/p&gt;

&lt;p&gt;Once you accept that a PDF is a drawing, every workaround below makes sense. None of them are editing a document. They are all either (a) adding a fake text layer, (b) converting the drawing back into a flow, or (c) throwing the drawing away and building a new one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 1: "I'll just convert it to Word and fix it there"
&lt;/h2&gt;

&lt;p&gt;For a clean, single-column, text-based PDF, &lt;code&gt;pdf2docx&lt;/code&gt; does a genuinely decent job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pdf2docx&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Converter&lt;/span&gt;

&lt;span class="n"&gt;cv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Converter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"proposal.pdf"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;cv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"proposal.docx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;cv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ten pages of single-column prose with real headings? It comes back recognisable. Fix the fonts, done in five minutes.&lt;/p&gt;

&lt;p&gt;Now feed it the documents that actually land in your inbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvgohrglwzhk8nal4gc3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvgohrglwzhk8nal4gc3n.png" alt="Converting a two-column PDF to Word turns into chaotic flying text boxes" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two columns.&lt;/strong&gt; The converter reads left to right across the full page width, because there is nothing in the file that says "column". A sidebar headline gets glued to the end of a body paragraph from the other column. You get sentences like "Revenue grew 14% quarter over quarter OUR MISSION" and then you spend twenty minutes separating them by hand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nested tables.&lt;/strong&gt; The outer table becomes a table. The inner ones become a stack of paragraphs, or a single row with 40 columns, depending on the day. Merged cells are a coin flip. Row heights collapse because Word recalculates them from the text, and the original heights were a drawing decision, not a text decision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A scanned page.&lt;/strong&gt; This is the fun one. There is no text on that page, only an image. So the converter faithfully inserts one giant picture into your Word file, and now you have a document where page 7 is a photo of a page and page 8 is editable text. Word's own importer and the Google Docs uploader behave the same way, because they are solving the same unsolvable problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When it still works:&lt;/strong&gt; single column, real text layer, no fancy tables, under about fifteen pages, and you only need to change wording. Then &lt;code&gt;pdf2docx&lt;/code&gt; is faster than everything else in this article. I use it maybe twice a month for exactly that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When it doesn't:&lt;/strong&gt; anything with a layout you care about. Conversion is lossy in the design dimension even when it is lossless in the text dimension. You will spend longer repairing the damage than rebuilding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 2: expecting OCR to make a scan look good
&lt;/h2&gt;

&lt;p&gt;If someone sends you a crooked scan and you want to hit &lt;code&gt;Cmd+F&lt;/code&gt; or copy a clause out of it, OCRmyPDF is the best free tool that exists. One command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ocrmypdf \
  --deskew \
  --clean \
  --rotate-pages \
  --force-ocr \
  scanned_lease.pdf \
  clean_lease.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what it actually printed on a four-page scanned lease, unedited, because the numbers are the interesting part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scanning contents  ━━━━━━━━━━━━━━━━━━━━ 100% 4/4 0:00:00
INFO   Start processing 4 pages concurrently (4 workers, unpaper=enabled)
INFO   1 [tesseract] Detected skew angle: -2.41° → deskewing + unpaper clean
INFO   2 [tesseract] Detected skew angle: -1.87° → deskewing + unpaper clean
INFO   3 [tesseract] Detected skew angle: +0.94° → deskewing + unpaper clean
INFO   4 [tesseract] Detected skew angle: -1.12° → deskewing + unpaper clean
OCR                    ━━━━━━━━━━━━━━━━━━ 100% 4/4 0:00:06
INFO   Postprocessing...
PDF/A conversion       ━━━━━━━━━━━━━━━━━━ 100% 4/4 0:00:01
Linearizing            ━━━━━━━━━━━━━━━━━━ 100% 1/1 0:00:00
INFO   Image optimization ratio: 1.42x · savings: 29.6%
INFO   Output file is a PDF/A-2B (as expected)

$ ls -lh scanned_lease.pdf clean_lease.pdf
-rw-r--r--  1 dev  staff   4.8M  scanned_lease.pdf   # image-only scan
-rw-r--r--  1 dev  staff   3.4M  clean_lease.pdf     # searchable PDF/A-2B (layout unchanged)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four pages, six seconds of OCR, 29.6% smaller, valid PDF/A-2B. Every page got its own skew estimate: -2.41°, -1.87°, +0.94°, -1.12°. That is a scanner fed by hand, corrected per page instead of globally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkbop7ehzfcpjcrdvrvqw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkbop7ehzfcpjcrdvrvqw.png" alt="Terminal running ocrmypdf with deskew, clean and force-ocr on a four-page scanned lease, output marked layout unchanged" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then the line that matters, sitting quietly in my own &lt;code&gt;ls&lt;/code&gt; output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# searchable PDF/A-2B (layout unchanged)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;layout unchanged.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That is not a bug report. It is the design goal. OCRmyPDF draws an invisible text layer underneath the original pixels so the page becomes searchable, selectable and archivable. It does not move a single element, because moving elements would destroy the evidentiary value of a scan. If a contract says what it says because of where the signature sits, you do not want a tool quietly re-laying out the page.&lt;/p&gt;

&lt;p&gt;So after OCR, your 2009 fax is a searchable 2009 fax: same grey cast, same coffee ring, same crooked margins. Useful, not a makeover.&lt;/p&gt;

&lt;h3&gt;
  
  
  The batch version, because one file is never one file
&lt;/h3&gt;

&lt;p&gt;Every time I OCR one file, there are forty more in a folder. This is the script I actually use. It runs four at a time, writes a per-file log, and skips anything already done, so you can &lt;code&gt;Ctrl+C&lt;/code&gt; and rerun without redoing work:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# batch-ocr.sh — OCR every PDF in a folder, resumable.&lt;/span&gt;
&lt;span class="c"&gt;# usage: ./batch-ocr.sh ./scans ./scans/ocr&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="nv"&gt;in_dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:?usage: batch-ocr.sh  [out-dir]}"&lt;/span&gt;
&lt;span class="nv"&gt;out_dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${2:-$in_dir/ocr}"&lt;/span&gt;
&lt;span class="nv"&gt;jobs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${JOBS:-4}"&lt;/span&gt;
mkdir -p &lt;span class="s2"&gt;"$out_dir"&lt;/span&gt;

find &lt;span class="s2"&gt;"$in_dir"&lt;/span&gt; -maxdepth 1 -type f -iname &lt;span class="s1"&gt;'*.pdf'&lt;/span&gt; -print0 \
&lt;span class="o"&gt;|&lt;/span&gt; xargs -0 -P &lt;span class="s2"&gt;"$jobs"&lt;/span&gt; -I&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt; bash -c &lt;span class="s1"&gt;'
    src="$1"; out="$2"
    base="$(basename "${src%.*}")"
    dst="$out/${base}-ocr.pdf"
    if [ -f "$dst" ]; then echo "skip  $base"; exit 0; fi
    if ocrmypdf --deskew --clean --rotate-pages --skip-text \
         --output-type pdfa-2 "$src" "$dst" 2&amp;gt;"$out/${base}.log"; then
      echo "ok    $base"
    else
      echo "FAIL  $base  (see ${base}.log)"; rm -f "$dst"
    fi
  '&lt;/span&gt; _ &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="s2"&gt;"$out_dir"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three details that took me a while to get right:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--skip-text&lt;/code&gt; instead of &lt;code&gt;--force-ocr&lt;/code&gt;. If a PDF already has a text layer on some pages (mixed exports are common), &lt;code&gt;--force-ocr&lt;/code&gt; rasterises and re-OCRs everything, which is slow and slightly degrades the image. &lt;code&gt;--skip-text&lt;/code&gt; leaves good pages alone.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-P "$jobs"&lt;/code&gt; on &lt;code&gt;xargs&lt;/code&gt;, not a &lt;code&gt;for&lt;/code&gt; loop. Tesseract is happy to use multiple cores, but four concurrent files beat one file using four threads, because I/O and PDF parsing overlap.&lt;/p&gt;

&lt;p&gt;Per-file stderr into &lt;code&gt;$base.log&lt;/code&gt;. When one file fails at page 37, you want the traceback, not a wall of interleaved output from four processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 3: "I'm a web dev, I'll rebuild it in HTML and print to PDF"
&lt;/h2&gt;

&lt;p&gt;This is the right answer and also a trap, because headless Chrome finds new ways to hurt you.&lt;/p&gt;

&lt;p&gt;The setup that finally stopped biting me:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// generate-pdf.mjs — node generate-pdf.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;chromium&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"playwright-core"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pathToFileURL&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:url"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;chromium&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"chrome"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;newPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;pathToFileURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"report.html"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;waitUntil&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"networkidle"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="c1"&gt;// webfonts and images have landed&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Chrome resolves fonts asynchronously. Skip this and page 1 renders in&lt;/span&gt;
&lt;span class="c1"&gt;// Times while page 2 renders in Inter, which is a fun bug to explain.&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fonts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"out.pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;printBackground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;// otherwise every background colour vanishes&lt;/span&gt;
  &lt;span class="n"&gt;preferCSSPageSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="c1"&gt;// trust @page size and margins, not format&lt;/span&gt;
  &lt;span class="n"&gt;displayHeaderFooter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;headerTemplate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`
      CloudPulse · Q4 Release Notes

`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;footerTemplate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`
      Confidential
      Page  of 

`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four of those options are load-bearing:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;waitUntil: "networkidle"&lt;/code&gt; waits until there have been no network requests for 500 ms. With &lt;code&gt;"load"&lt;/code&gt; you get a PDF where the logo is a broken image icon, roughly one run in five.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;document.fonts.ready&lt;/code&gt; is the one nobody knows about. &lt;code&gt;page.pdf()&lt;/code&gt; can run before the font swap finishes, and Chrome will happily fall back to a system serif for the first page only. If your PDF has two typefaces and you only specified one, this is why.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;printBackground: true&lt;/code&gt; is required or Chrome drops background colours and borders. You will then spend an hour adding &lt;code&gt;-webkit-print-color-adjust: exact&lt;/code&gt; and wondering why it changed nothing. Both are needed, for different reasons: one tells Chrome to paint backgrounds at all, the other stops the print path from "optimising" them away.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;preferCSSPageSize: true&lt;/code&gt; makes the &lt;code&gt;@page&lt;/code&gt; rule authoritative. Without it, Chrome uses the &lt;code&gt;format&lt;/code&gt; option and your carefully measured 16 mm margins become whatever the default is.&lt;/p&gt;

&lt;h3&gt;
  
  
  The CSS that actually matters
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@page&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;A4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;18mm&lt;/span&gt; &lt;span class="mi"&gt;16mm&lt;/span&gt; &lt;span class="mi"&gt;20mm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="cm"&gt;/* Without this, Chrome strips background colours in the print path */&lt;/span&gt;
  &lt;span class="nl"&gt;-webkit-print-color-adjust&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;exact&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;print-color-adjust&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;exact&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Stop Chrome from slicing a table row or a card in half */&lt;/span&gt;
&lt;span class="nc"&gt;.card&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;tr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;blockquote&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;figure&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;break-inside&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;avoid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;page-break-inside&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;avoid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Repeat table headers on every page */&lt;/span&gt;
&lt;span class="nt"&gt;thead&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;table-header-group&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;tfoot&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;table-footer-group&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Do not leave a heading stranded at the bottom of a page */&lt;/span&gt;
&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h3&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;break-after&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;avoid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Three lines minimum before a break, so you never get a widow */&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;orphans&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;widows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even with all of that, the print path finds creative ways to hurt your feelings:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnwdstmn7xktgeeaxe4ie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnwdstmn7xktgeeaxe4ie.png" alt="CSS media print slicing a table row across page one and page two" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The one that cost me the most time: &lt;code&gt;break-inside: avoid&lt;/code&gt; on a &lt;code&gt;is honoured, but only if the row is not taller than a page. A 40-row table wrapped in a single&lt;/code&gt; with &lt;code&gt;break-inside: avoid&lt;/code&gt; on the tbody will simply overflow and clip. Put the rule on the row, never on the body.&lt;/p&gt;

&lt;h3&gt;
  
  
  I timed it, because "Chrome is slow" is not a number
&lt;/h3&gt;

&lt;p&gt;Same one-page report, same content, both ways, one M-series Mac, five runs each, median shown:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Chrome 158 &lt;code&gt;page.pdf()&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Typst 0.15.1&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Wall time (median of 5)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.20 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.17 s&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fastest / slowest&lt;/td&gt;
&lt;td&gt;1.88 s / 2.29 s&lt;/td&gt;
&lt;td&gt;0.16 s / 0.17 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Peak RSS, whole command&lt;/td&gt;
&lt;td&gt;~200 MB&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~42 MB&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output size&lt;/td&gt;
&lt;td&gt;72 KB&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;39 KB&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cold start&lt;/td&gt;
&lt;td&gt;browser launch and teardown dominate&lt;/td&gt;
&lt;td&gt;none, it is a single binary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fonts&lt;/td&gt;
&lt;td&gt;whatever the OS has installed&lt;/td&gt;
&lt;td&gt;embedded or fetched, deterministic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Page breaks&lt;/td&gt;
&lt;td&gt;you fight CSS&lt;/td&gt;
&lt;td&gt;computed by the layout engine&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;About &lt;strong&gt;12× slower and 5× heavier&lt;/strong&gt; for the same page. And this is the best case for Chrome: one page, no images, no webfonts to download. Add a 3 MB hero image and a Google Font and the gap widens.&lt;/p&gt;

&lt;p&gt;Peak RSS is what &lt;code&gt;/usr/bin/time -l&lt;/code&gt; reports for the whole command. Chrome forks helper processes, so the real total footprint is higher than 200 MB. Typst at 42 MB is one process and one binary.&lt;/p&gt;

&lt;p&gt;Chrome is not wrong, it is just expensive per run. If your data already lives in a React app, &lt;code&gt;page.pdf()&lt;/code&gt; costs nothing to adopt. Two hundred nightly invoices take 7 minutes in Chrome and 34 seconds in Typst.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Typst version, which is one file and no browser
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// release-notes.typ
#set page(
  paper: "a4",
  margin: (x: 16mm, y: 18mm),
  footer: context [
    #set text(size: 8pt, fill: luma(130))
    CloudPulse Systems Inc — Platform Engineering
    #h(1fr)
    Page #counter(page).display() of #counter(page).final().first()
  ],
)
#set text(font: ("Helvetica Neue", "Arial"), size: 10.5pt, fill: luma(20))
#set par(justify: true, leading: 0.62em)

#show heading.where(level: 2): it =&amp;gt; block(above: 1.4em, below: 0.6em)[
  #set text(size: 13pt, weight: "semibold")
  #it.body
  #v(-0.45em)
  #line(length: 100%, stroke: 0.6pt + luma(210))
]

#let kpi(value, label) = block(
  inset: 9pt,
  stroke: 0.6pt + luma(226),
  radius: 4pt,
  [#text(size: 17pt, weight: "bold")[#value] #linebreak()
   #text(size: 9pt, fill: luma(110))[#label]],
)

#text(size: 24pt, weight: "bold")[Q4 Platform Release Notes]
#v(2pt)
#text(size: 9pt, fill: luma(110))[v3.8 · Core Platform Team · 12 December 2026]
#v(12pt)

#grid(columns: (1fr, 1fr, 1fr), gutter: 8pt,
  kpi[42%][faster queries],
  kpi[SAML 2.0][enterprise SSO],
  kpi[v3][REST and webhook],
)

== Endpoint performance
#table(
  columns: (1fr, auto, auto, auto, 1fr),
  inset: (x: 6pt, y: 5pt),
  stroke: (x, y) =&amp;gt; if y == 0 { 1pt + luma(180) } else { 0.4pt + luma(232) },
  fill: (x, y) =&amp;gt; if y == 0 { luma(244) },
  align: (left, right, right, right, left),
  table.header([*Endpoint*], [*p50*], [*p99*], [*Delta*], [*Scope*]),
  [GET /v2/invoices/:id], [148 ms], [610 ms], [-73.6%], [Global edge],
  [POST /v2/payments/capture], [96 ms], [310 ms], [-41.2%], [US-East],
  [POST /v2/webhooks/verify], [12 ms], [44 ms], [-8.0%], [Dead-letter queue],
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;typst compile release-notes.typ out.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No browser, no &lt;code&gt;@media print&lt;/code&gt;, no 200 MB of Chromium. Page breaks are the layout engine's job. &lt;code&gt;counter(page).final()&lt;/code&gt; gives you "Page 2 of 3" without a second pass.&lt;/p&gt;

&lt;p&gt;The catch: Typst is not HTML, so your React components do not port. For a one-off report, rewriting it in a new markup language is a day you will not get back. If you generate the same document shape daily, it pays for itself in a week.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 4: compliance says the file cannot leave the building
&lt;/h2&gt;

&lt;p&gt;Never upload client contracts, medical records or payroll to &lt;code&gt;free-pdf-online-2026.biz&lt;/code&gt;. Obvious when written down, surprisingly common at 6 PM on a Friday.&lt;/p&gt;

&lt;p&gt;Stirling-PDF is the answer I keep giving, because it is one container and it covers redaction, signing, OCR, splitting, merging, compression and about sixty other operations. This compose file is the one I run, based on their docs, with analytics turned off and a memory ceiling so it cannot eat the whole machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stirling-pdf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docker.stirlingpdf.com/stirlingtools/stirling-pdf:latest&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;stirling-pdf&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"8080:8080"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./stirling/configs:/configs&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./stirling/logs:/logs&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./stirling/tessdata:/usr/share/tessdata&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./stirling/pipeline:/pipeline&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./stirling/storage:/storage&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;SYSTEM_ENABLEANALYTICS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"false"&lt;/span&gt;   &lt;span class="c1"&gt;# no PostHog, no Scarf pixel
&lt;/span&gt;      &lt;span class="na"&gt;LANGS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;en_GB&lt;/span&gt;
    &lt;span class="na"&gt;mem_limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;4g&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;SYSTEM_ENABLEANALYTICS=false&lt;/code&gt; is the one that matters for a bank or a hospital. Their docs are explicit that document contents are never sent, but the server does report version, OS, CPU, memory and operation counts to PostHog's EU servers. Turning it off is one line. Do it before someone in security asks.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mem_limit: 4g&lt;/code&gt; because OCR on a 300-page scan will otherwise grow until the kernel stops it, and a container that gets OOM-killed mid-merge is a bad afternoon.&lt;/p&gt;

&lt;p&gt;Then drive it from a script instead of clicking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# merge two files, returns one PDF&lt;/span&gt;
curl -sS -X POST http://localhost:8080/api/v1/general/merge-pdfs \
  -F &lt;span class="s2"&gt;"files=@cover.pdf"&lt;/span&gt; \
  -F &lt;span class="s2"&gt;"files=@body.pdf"&lt;/span&gt; \
  -o merged.pdf

&lt;span class="c"&gt;# OCR a scan, keep the original images&lt;/span&gt;
curl -sS -X POST http://localhost:8080/api/v1/misc/ocr-pdf \
  -F &lt;span class="s2"&gt;"fileInput=@scan.pdf"&lt;/span&gt; \
  -F &lt;span class="s2"&gt;"languages=eng"&lt;/span&gt; \
  -F &lt;span class="s2"&gt;"deskew=true"&lt;/span&gt; \
  -o scan-ocr.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Endpoint names move between releases, so check &lt;code&gt;/v1/api-docs&lt;/code&gt; on your own instance before you hardcode them in a pipeline. The shape stays the same: multipart upload in, PDF bytes out.&lt;/p&gt;

&lt;p&gt;The honest cost: you now operate a service. A container, a volume for the Tesseract data, backups, and someone who remembers to pull a new image. If you do three PDFs a year, use the desktop tool instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 30-second decision tree
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One typo in a document that is otherwise fine?
└── PDF editor, desktop, offline. Do not rebuild anything.

Scanned, and you need Cmd+F or a legal archive copy?
└── OCRmyPDF. It says "layout unchanged" and means it.

File can't leave the network, or you need 400 operations?
└── Stirling-PDF in Docker, analytics off.

Data already in your app, generating the same doc repeatedly?
└── Typst if you can own the template, Playwright if you can't.

Looks like a 2009 fax and the words are all correct?
└── This is a layout problem, not a file problem. Keep reading.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last branch is the one that took me years to name. Every tool above is a toolbox for &lt;strong&gt;content&lt;/strong&gt;: find the text, remove the field, fix the skew, merge the files. None of them touch how the page &lt;strong&gt;reads&lt;/strong&gt;. Which is why a technically perfect 26-page questionnaire can still get skimmed, ignored and answered with "can you send a cleaner version".&lt;/p&gt;

&lt;h2&gt;
  
  
  The gap: the file is fixed, the layout is still 2009
&lt;/h2&gt;

&lt;p&gt;This is the part where I have to disclose something. The tool in this section is one I work on. The four tools above are in my actual workflow and I have said what each one is bad at. Nobody paid for a placement here.&lt;/p&gt;

&lt;p&gt;The job that none of them do is: take a document whose words and numbers are correct, and give it a layout a reader can scan. Not rewrite it. Not convert it. Rebuild the page around the same content.&lt;/p&gt;

&lt;p&gt;Here is what that looks like on four documents that have nothing in common except being ugly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 1: an incident postmortem that got printed and annotated
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F556t066hvsi8psnuklhj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F556t066hvsi8psnuklhj.png" alt="The same incident postmortem as a crooked, highlighter-marked scan on the left and rebuilt as a clean technical whitepaper on the right" width="800" height="561"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The original is a four-page draft printed at 03:14, marked up with a highlighter and a red pen, then scanned back at an angle. The p99 checkout latency spike to 1,840 ms and the 4.82% error rate survive only because somebody circled them.&lt;/p&gt;

&lt;p&gt;The rebuild keeps &lt;code&gt;#INC-4092&lt;/code&gt;, the DO NOT DISTRIBUTE header and every row of the latency table, and drops the scan artifacts. The failing rows get colour, the handwritten FIX BEFORE LAUNCH note becomes a callout beside the terminal output, and the three remediation steps stop being handwriting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 2: a principal architect's resume
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7dw05x6zniz964x2bg1a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7dw05x6zniz964x2bg1a.png" alt="Marcus Vance's resume as a black-bordered, highlighter-marked page on the left and rebuilt as a clean two-column timeline on the right" width="800" height="561"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Marcus Vance has 10+ years in distributed systems, and the original buries that under black boxes, highlighter on every section heading, star ratings for skills and a typo in the word latency.&lt;/p&gt;

&lt;p&gt;The rebuild keeps every metric ($1.8M/yr cut from AWS, p99 from 420 ms to 38 ms, 85,000 TPS, 99.995% uptime) and swaps the stars for percentage bars and the boxes for a timeline. Same sentences, including the 12TB/day ingestion line.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 3: a $23,760 quote that arrived creased
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fezmzsmqotv38kkk7s831.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fezmzsmqotv38kkk7s831.png" alt="A creased, desk-lamp photo of quote #QT-2026-884 on the left and rebuilt in warm white with a full-width total band on the right" width="800" height="561"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one is a scan of a printed quote: &lt;code&gt;#QT-2026-884&lt;/code&gt; from Apex Systems Engineering to Meridian Logistics, folded twice, shot under a desk lamp, with a blue stamp sitting on top of the header.&lt;/p&gt;

&lt;p&gt;The rebuild puts the total in a full-width band, keeps all seven line items and the 40/40/20 schedule verbatim ($9,504 on signing, $9,504 at UAT sign-off, $4,752 at launch), and keeps the red URGENT APPROVED stamp, because that stamp is the point of the document.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 4: release notes that were never meant to be a document
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2ugfw627ph9o1lxmbxwh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2ugfw627ph9o1lxmbxwh.png" alt="A Confluence page printout with its sidebar and URL footer on the left and rebuilt as a launch-style release brief on the right" width="800" height="561"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The original is what Cmd+P on a Confluence page produces: the left sidebar comes along, the breadcrumb is clipped at the right edge, and the wiki URL is printed in the footer.&lt;/p&gt;

&lt;p&gt;The rebuild keeps the module table, all four impact numbers (18% faster close, 62% less login dropoff, 3.4x throughput, 99.98% delivery) and the breaking-change notice about &lt;code&gt;/v1/tokens&lt;/code&gt;, and gives the three charts room to breathe.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where this stops being the right answer
&lt;/h3&gt;

&lt;p&gt;The honest edges:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handwriting.&lt;/strong&gt; A scanned form with a pen signature over printed text will confuse it. Check those pages by hand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dense small type in non-Latin scripts.&lt;/strong&gt; 7pt Japanese or Chinese footnotes occasionally come back with a wrong glyph. Proofread before sending.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Merged table cells and footnotes.&lt;/strong&gt; Complex tables can shift by a few points between source and rebuild. Compare side by side, especially for anything with money in it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It is not a text editor.&lt;/strong&gt; If the job is rewriting paragraphs, go back to the desktop editor. This is a layout pass, not a word processor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compliance.&lt;/strong&gt; The cleanup utilities (deskew, pure black and white, searchable OCR) run in your browser and cost nothing. The layout pass runs on our servers and is metered, two credits per page, with two free pages before sign-in and three more after. If your policy forbids uploads, stay on Stirling-PDF plus OCRmyPDF and skip this section entirely.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 80/20 version
&lt;/h2&gt;

&lt;p&gt;If you read nothing else, this table is the whole article:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;One wrong date in a 40-page contract&lt;/td&gt;
&lt;td&gt;Desktop PDF editor&lt;/td&gt;
&lt;td&gt;Editing one object is not a rebuild&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;300 scanned pages, need search&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ocrmypdf --deskew --clean&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;6 seconds per 4 pages, archive-grade&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;400 files, same operation&lt;/td&gt;
&lt;td&gt;Stirling-PDF + &lt;code&gt;curl&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Runs on your metal, scriptable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Invoices every night from a DB&lt;/td&gt;
&lt;td&gt;Typst, or Playwright if you must&lt;/td&gt;
&lt;td&gt;12× faster, 5× lighter, deterministic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Correct words, unreadable layout&lt;/td&gt;
&lt;td&gt;A visual rebuild pass&lt;/td&gt;
&lt;td&gt;The only branch that changes how it reads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scanned, ugly, needs signing&lt;/td&gt;
&lt;td&gt;OCR, then rebuild, then sign&lt;/td&gt;
&lt;td&gt;Backwards wastes an hour&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last row is the one people get wrong: OCR-ing a page after you rebuilt it means doing the expensive step twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your turn
&lt;/h2&gt;

&lt;p&gt;What is the worst PDF anyone has ever sent you to "just fix real quick"?&lt;/p&gt;

&lt;p&gt;My record is a 12-page vendor quote that went Excel spreadsheet, screenshot, pasted into PowerPoint, printed, photographed on a wooden kitchen table, then emailed as a 28 MB PDF.&lt;/p&gt;

&lt;p&gt;If you have a document that is correct and still unreadable, the rebuild path is at &lt;a href="https://redesignpdf.com/r/redesign-pdf?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=devto_nevo_v2" rel="noopener noreferrer"&gt;redesignpdf.com&lt;/a&gt;. Two pages free, no account needed.&lt;/p&gt;

&lt;p&gt;And if a table comes back shifted by four points, tell me in the comments. That is the failure I most want to see, because it is the one that gets fixed next.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>opensource</category>
      <category>tools</category>
    </item>
  </channel>
</rss>
