Skip to content

v2.2.0 — Retype a paragraph, and let the page make room

Choose a tag to compare

@romizone romizone released this 08 Aug 08:47
· 2 commits to main since this release

Editing text in a PDF stops being "replace this fragment" and becomes "retype this paragraph". Double-click a paragraph, type, and the whole paragraph re-wraps — in the document's own font, keeping its justification and its inline bold and italic. If it needs more lines, everything below it moves down to make room.

This release folds in both 2.1.0 (reflow) and 2.2.0 (making room).

Editing text

  • Word-like re-wrapping. Add or remove words and the lines break again around them, instead of the replacement being squeezed into the box the old text happened to occupy.
  • The document's own font. Text is measured from the PDF's own width tables and drawn with the page's existing font resources, so nothing is re-embedded and the file does not grow with each edit. Previously every edit was redrawn in a substituted base-14 face — on a document set in Georgia that was 9% narrower and broke every line in a different place.
  • Justification that actually justifies, and inline styling that survives: fixing a typo no longer flattens the bold phrase three words later.
  • Content below moves. Grow a paragraph and the text, bullets, tables, images, links, form fields and annotations beneath it shift by exactly that much; shrink it and the space closes back up. On a two-column page only the edited column moves.

What it refuses, and says so

A paragraph is only offered for reflow when re-wrapping it is safe. Tables, dot-leader contents pages, rotated pages, multi-column layouts, invisible OCR text layers, letter-tracked display type, and paragraphs whose font cannot be measured are all declined with a plain-English reason.

An edit that would push content past the bottom of the page is refused too — PDF discards that content without warning, so it is never attempted. There is no flow onto the next page; PDF has no page-flow model, and neither does Acrobat.

Typing a character the document's font does not contain is reported rather than silently substituted, and nothing is written.

Safety

Every edit is verified before it commits: each word outside the edited paragraph must keep its text and land exactly where it should, within 0.05 pt. Anything else rolls the whole edit back. One reflow is one undo step.

Installing

macOS blocks the app on first launch because it is ad-hoc signed rather than notarised. After dragging it to Applications:

xattr -dr com.apple.quarantine /Applications/PdfRomeo.app

Under the hood

New engine modules: fontmetrics.py (exact measurement from the PDF's own tables — 0.0001 pt across base-14, fully-embedded, subsetted and simple TrueType fonts), textblocks.py (paragraph reconstruction — a PyMuPDF "block" is not a paragraph, in either direction), reflow.py (line breaking and content-stream emission), and pageroom.py (free-space detection and banded page shifting).

tests/test_reflow.py adds 256 checks; the full suite is 256 + 139 + 49 + 43 tool panels + 23 regression + engine smoke, all green.

Design and the measurements behind every decision: docs/paragraph-reflow-spec.md

Full changelog: https://github.com/romizone/pdfromeo/blob/main/CHANGELOG.md