Skip to main content
Python PDF SDK

Python PDF SDK for Editing Existing PDFs

Target and modify existing PDF content from Python 3.10+. Use context-managed sessions, explicit layout modes, and operation diagnostics in scripts, automation jobs, and backend applications.

Run the first edit and check the result

Download the public quick-start PDF as input.pdf. The example replaces one word on page one and rejects an unexpected result before saving.

Use Python interfaces for text, layout, pages, and PDF objects

Extract semantic reading units from a document or page

Analyze the current session as classified text blocks with reading order, source-element provenance, page-space bounds, and relationships. Each call reflects the current session state.

Read the structured-text guide

Choose between anchored placement, reflow when possible, and required reflow

Select how replacement text should behave when its length changes: keep it anchored to the original position, reflow it when the document structure supports reflow, or require reflow and return an error when it cannot be applied.

  • source_anchored() retains the selected source position.
  • reflow_when_supported() permits source-anchored fallback.
  • require_reflow() reports an error for unsupported targets.

Keep synchronous PDF work off the FastAPI event loop

The route reads the uploaded bytes, runs the synchronous client in FastAPI's thread pool, checks errors, and returns the edited PDF. Configure upload limits and authentication with FastAPI dependencies or middleware, and map failures with registered exception handlers.

See the FastAPI PDF workflow guide for the dedicated framework page.

Check text editability, reflow diagnostics, and output requirements

RuntimePython 3.10+
Client modelSynchronous
InputBytes, paths, strings, binary files
ProcessingHosted PDFDancer service
  • PDFDancer is a synchronous hosted-service client. Move calls off an asynchronous framework event loop.
  • Text selectors require editable PDF text; outlines, paths, page images, and unusual encodings may not match.
  • A successful change count does not prove that reflow occurred. Inspect change diagnostics and rendered output.
  • Registered fonts still need glyph coverage for every replacement character.
  • Saving output does not certify PDF/A conformance or preserve an existing digital signature.
  • Deleting selected text is an editing operation, not security redaction.

Continue from the quick start to the Python API

Python PDF SDK questions

Start Using PDFDancer Today

Get started in seconds with our free tier. No credit card required.

Want to evaluate first? Run the anonymous quick start.