DEV Community

Michael Lip
Michael Lip

Posted on • Originally published at zovo.one

Editing PDFs Is Harder Than It Should Be and Here Is Why

PDF was designed as a final output format not an editing format. The internal structure stores text as positioned glyphs not as flowing paragraphs. When you edit text in a PDF you are repositioning individual character groups not editing a document.

How PDF stores text

In HTML, "Hello World" is a text node that flows with the document. In PDF, the same text might be stored as:

BT
/F1 12 Tf
100 700 Td
(Hello World) Tj
ET
Enter fullscreen mode Exit fullscreen mode

This says: begin text block, use font F1 at 12pt, move to position (100, 700), draw the string "Hello World", end text block.

Every text element has an absolute position. There is no concept of "paragraphs" or "lines" in the PDF specification. A paragraph is just multiple positioned text chunks that happen to be near each other vertically.

Why editing is hard

When you delete a word from a PDF "paragraph," the remaining words do not reflow. Each word stays at its original position. The editor must recalculate positions for every subsequent word in the visual paragraph, which requires:

  1. Identifying which positioned text chunks form a paragraph (heuristic, not explicit)
  2. Measuring the width of the modified text in the specific font
  3. Repositioning subsequent chunks
  4. Handling line breaks when text gets longer or shorter
  5. Repositioning chunks on subsequent pages if the paragraph length changes

This is why most PDF editors only support basic operations well: adding text (new positioned element), adding signatures (image overlay), filling forms (writing to form field coordinates), and annotating (adding overlay elements).

What works reliably

  • Adding text annotations - New positioned elements, no reflow needed
  • Filling form fields - Writing to predefined positions
  • Adding images/signatures - Overlay operations
  • Highlighting/underlining - Drawing operations on known text positions
  • Redacting - Drawing opaque rectangles over content
  • Reordering pages - Updating the page reference table

What breaks frequently

  • Editing existing text - Reflow issues
  • Changing fonts - Metrics change, positions break
  • Reflowing paragraphs - The fundamental problem
  • Editing scanned documents - There is no text to edit, only images

For making common PDF edits without desktop software, I built an editor at zovo.one/free-tools/pdf-editor. It handles annotations, text additions, form filling, and signature placement. These are the operations that work reliably in the browser.


I'm Michael Lip. I build free developer tools at zovo.one. 500+ tools, all private, all free.

Top comments (0)