pikepdf · open, edit and repair PDFs in Python, losslessly
4 months ago
You have a PDF to reshape in code. Rotate scanned pages, drop a blank one, split or merge, or repair a file that will not open. pikepdf does all of it in a few lines of Python, and it does it losslessly.
Ask about this presentation
Chapters
Show transcriptHide transcript
You have a PDF to reshape in code. Rotate scanned pages, drop a blank one, split or merge, or repair a file that will not open. pikepdf does all of it in a few lines of Python, and it does it losslessly.
pikepdf is a Python library to create, manipulate, and repair PDFs. It wraps qpdf, a mature and battle tested PDF engine, so it reads compressed object streams, repairs damaged files, and rewrites them for fast web view. Things the pure Python libraries cannot do. Install it with pip.
pikepdf uses one object for reading, writing, and merging. Open a file with a context manager; the simplest round trip is open and save. Pages behave like a Python list. Ask for their length, index into them, and slice them. Page numbers start at zero.
Now make a real edit. Pages act like a list, so you can slice them. Delete pages two and three, and this four page file becomes two: the first page and the last. Or rotate every page and save, the landing page's own example.
Because qpdf sits underneath, that same open and save loop does much more. Open a broken PDF and just save it, and qpdf rebuilds its structure. That is repair, in two lines. You can also encrypt on save, or build a new PDF from scratch.
Save is lossless: qpdf rewrites the file's structure without touching your content, so nothing is re-encoded. Save again and keep editing. Just do not overwrite the file you opened while it is still open.
That is the whole idea. One Pdf object, pages that act like a list, and a lossless save. From there you also get images, metadata, forms, attachments, and full qpdf jobs when you need them. Install it with pip, and start from the docs.
Up next
2:03cargo-nextest · a next-generation test runner for Rust
@github
4 months ago
1:35mq · jq, but for Markdown
@github
4 months ago
1:24Mimesis · realistic, locale-aware fake data in one line
@github
4 months ago
1:22tfswitch · the right Terraform version, automatically
@github
4 months ago
1:21PyPDFForm · fill a PDF form in Python in a few lines
@github
4 months ago
1:35MCP-UI - interactive apps for MCP tools
@github
4 months ago
1:39workmux - parallel coding agents in isolated worktrees
@github
4 months ago
1:33Pumpkin - start a Rust Minecraft server
@github
4 months ago
1:39Bifrost - your first reliable AI gateway
@github
4 months ago
1:39Honcho - memory that reasons across sessions
@github
4 months ago
1:56agentgateway · one governed proxy for your agent traffic
@github
4 months ago
1:25Compodoc · instant documentation for your Angular app
@github
4 months ago






