How to Edit Text Inside Any PDF Without Overlays

The Problem

Replacing text inside an existing PDF is hard.

Most libraries can only overlay new text, use a different font, or force you to delete and recreate entire text objects.

PDFs don't store text the way documents do. They store positioned glyph IDs along embedded subset fonts. That means:

  • You can add new text using your own fonts
  • But you can't reliably edit the existing text with its original font, spacing, or flow.

Technical Explanation

  • Text is stored as glyph IDs, not Unicode
  • Embedded fonts contain only the glyphs used - everything else is missing.
  • Glyph ID mappings are not standardized. Glyph 79 might be "P" in one font and "f" in another.
  • Text is positioned glyph-by-glyph. PDFs have no concept of lines or paragraphs.
  • Kerning, spacing adjustments, and transformation matrices make it nearly impossible to reproduce the original look after editing.
Source PDF
Saved PDF
cursor

Residential Lease Agreement

Contract No. LA-2025-00847

PARTIES TO THE AGREEMENT:

Landlord: Acme Property Management Ltd.

Tenant: Sarah Johnson

Property Address: 42 Maple Street, Apartment 5B, Portland, OR 97201

TERMS AND CONDITIONS

1. Rental Period

The Tenant agrees to lease the Property for a fixed term commencing on January 1, 2025 and continuing through December 31, 2025, unless terminated earlier in accordance with the provisions of this Agreement.

2. Monthly Rent

The Tenant shall pay to the Landlord monthly rent in the amount of $1,850.00, due on the first day of each calendar month. Rent payments shall be made by electronic transfer or certified check.

3. Lease Validity

The parties acknowledge that this lease agreement is valid until 31/12/2025. Either party may terminate this Agreement by providing sixty (60) days written notice prior to the intended termination date, subject to the terms herein.

4. Security Deposit

The Landlord shall maintain the Property in habitable condition and shall be responsible for all major repairs. The Tenant shall be responsible for minor maintenance and shall promptly report any damage or needed repairs to the Landlord.

5. Utilities

The Tenant shall be responsible for payment of all utilities including electricity, gas, water, internet, and cable services for the duration of the lease term.

Landlord Signature & Date

Tenant Signature & Date

This document constitutes a legally binding agreement. Both parties should retain a signed copy.

API Calls

Full Code

Works instantly in guest mode — no API key required.

How PDFDancer Solves This

  • Reconstructs lines, words, and paragraphs from low-level PDF drawing ops
  • Maps glyph IDs back to Unicode
  • Preserves original kerning, spacing, and transforms
  • Determines whether the embedded font can be reused
  • If not, picks a visually similar OFL font and reflows precisely
  • Applies true in-place edits - no overlays, no layout shifts
  • Maintains original text boundaries (no flow breaks, no reflow unless explicitly requested)