# lopdf

> A Rust library for PDF document manipulation.

Source: https://talira.ai/catalog/lopdf-8dj842a3
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [documents / pdf / manipulation](https://talira.ai/categories/documents/pdf/manipulation), [languages / rust](https://talira.ai/categories/languages/rust)
- Licence: MIT[^2][^3]
- Pricing: Free and open source[^2][^3]
- Pricing notes: MIT, except the Montserrat font in the repository.
- Free tier: yes[^2][^3]
- Self-hostable: yes[^2]
- Creator: Junfeng Liu (J-F-Liu)

lopdf is a Rust library that loads a PDF into an in-memory object model (dictionaries, streams, object IDs) that you can read, change and save again, or build up from nothing. It parses and writes cross-reference streams and object streams, decrypts and encrypts documents, extracts text from pages, edits content streams, deletes and renumbers pages and objects, compresses streams, works with bookmarks and outlines, and can append incremental updates to an existing file. Optional features add async loading with [Tokio](https://talira.ai/catalog/tokio-5dcaannt.md), serde support, image embedding and TrueType font embedding via skrifa. It works at the level of PDF objects, so tasks such as merging documents are written by the caller, as its README's examples show.

## Links

- GitHub: https://github.com/J-F-Liu/lopdf
- Docs: https://docs.rs/lopdf

## Problems it solves

- open an existing PDF in Rust, change some objects and save it again
- merge several PDF files into one from a Rust program
- delete pages from a PDF or renumber its objects in Rust
- pull the text out of PDF pages in Rust without a C library
- decrypt a PDF that has an empty user password so my Rust code can process it
- rewrite a page's content stream to add or replace drawing operations
- make PDFs smaller by packing objects into object streams and compressing streams
- read a PDF's bookmarks, outline and table of contents from Rust
- append an incremental update to a PDF instead of rewriting the whole file
- build a PDF object by object with a dictionary macro in Rust
- load PDFs asynchronously in a Tokio service
- replace the XML data packet inside a PDF form's XFA stream and save the file from Rust
- edit one stream object in an existing PDF and write the change as an incremental update

## Features

- load, edit and save PDF documents as an object model
- create PDFs from scratch with a dictionary! macro and content operations
- object streams and cross-reference streams (PDF 1.5+), reading and writing
- decryption (automatic for empty passwords) and encryption
- text extraction from pages
- delete pages, prune and renumber objects, compress and decompress streams
- bookmarks, outlines, destinations and table of contents
- incremental updates through IncrementalDocument
- optional async loading (Tokio), serde, image embedding and TrueType font embedding via skrifa
- parallel object-stream and cross-reference parsing with rayon

## Limitations

- Doesn't stream large PDFs: it keeps the whole document in memory as objects until it saves the file[^1]
- May not decrypt every encrypted PDF: some encryption algorithms aren't fully supported, and only empty passwords open automatically[^1]

## Capabilities

- Has official SDKs: plan not known

## Trust

Overall: 0.23 out of 1.
Signals: backing 0.20, extensibility 0.00.

- created by Junfeng Liu (J-F-Liu)

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [pdfium-render](https://talira.ai/catalog/pdfium-render-yyd0t2g5.md): A high-level idiomatic Rust wrapper around Pdfium, the C++ PDF library used by the Google Chromium project.
- [pdf-rs](https://talira.ai/catalog/pdf-rs-p2j8k7qt.md): Rust library to read, manipulate and write PDF files.
- [pdf-writer](https://talira.ai/catalog/pdf-writer-1hvagsht.md): A step-by-step PDF writer.
- [qpdf](https://talira.ai/catalog/qpdf-m21640ex.md): A content-preserving PDF document transformer
- [pdfcpu](https://talira.ai/catalog/pdfcpu-ctccs8g5.md): PDF tooling for Go and the command line
- [pdf-lib](https://talira.ai/catalog/pdf-lib-80dtat8x.md): Create and modify PDF documents in any JavaScript environment.

## Sources

[^1]: https://github.com/J-F-Liu/lopdf/blob/main/README.md (checked 20 Nov 2026)
[^2]: https://crates.io/crates/lopdf (checked 20 Nov 2026)
[^3]: https://github.com/J-F-Liu/lopdf/blob/main/LICENSE (checked 20 Nov 2026)
