v1.0 · Stable · Apache-2.0

PDFSP
PDF Scene Patch

Portable, verifiable JSON format for mutating a PDF scene graph — the PDF equivalent of JSON Patch (RFC 6902).

examples/replace-text.pdfpatch
{
  "spec": "PDFSP/1.0",
  "target": "sha256:3a7f...",
  "ops": [
    {
      "op": "replace_text",
      "target": "text:'invoice #42'",
      "text": "invoice #43"
    },
    {
      "op": "fill_field",
      "label": "Total",
      "text": "1 250,00 €"
    }
  ],
  "contract": {
    "only_touch": ["e12", "e13"]
  },
  "verify": {
    "expect": ["invoice #43"],
    "absent": ["invoice #42"]
  }, 
…

Why it exists

PDFSP defines a portable, verifiable JSON format for describing mutations of a PDF document's scene graph. A patch describes what to change, not how to change it: it can be applied by any conforming engine, replayed on related documents, rebased onto newer revisions, and inverted for rollback.

Key properties

Semantic selectors

Address elements by page[2], table[0].row[1].cell[0], section['Résumé'].para[1] or text:'invoice #42' — not fragile coordinates.

Contracts

only_touch scopes exactly which ids a patch may mutate; violations abort or report contract_violation.

Post-conditions

verify.expect / verify.absent run after application — the engine reports checks, not vibes.

Atomic or best-effort

meta.atomic: true gives all-or-nothing application; default mode reports every issue and continues.

Inversion

Every op class has a canonical inverse — rollback without snapshots.

Typed issues

bad_op, target_not_found, stale_target, contract_violation… never a silent failure.

Related specifications

SpecFull nameRelation
PDFDTPDocument Transaction ProtocolCarries PDFSP ops inside transactions (ops field, SPEC §3).
PDFADPDF Agent DescriptorDeclares the id_scheme engines use for element ids (SPEC §5).