A Rust library for creating, merging, modifying, and decrypting PDF documents with support for modern object streams.
lopdf is a comprehensive Rust library for programmatic PDF document manipulation. It provides low-level access to the PDF specification, enabling developers to create, modify, merge, and decrypt PDF files with fine-grained control. The library prioritizes a complete in-memory representation for precise control and smaller output files.
Rust developers who need to generate, modify, or analyze PDF documents programmatically, such as those building document automation tools, report generators, or PDF processing pipelines.
Developers choose lopdf for its adherence to the PDF specification, fine-grained control over document structure, and modern features like object stream compression for significant file size reduction. It balances low-level specification access with practical high-level APIs.
A Rust library for PDF document manipulation.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports object streams and cross-reference streams, reducing file size by 11-61% as demonstrated in the SaveOptions examples and benchmarks for PDF 1.5+ compliance.
Can automatically decrypt PDFs encrypted with empty passwords on load, simplifying access to protected content without additional code, as shown in the decryption example.
Provides low-level access to PDF objects and streams, enabling precise manipulation of pages, fonts, and document structure, evidenced by the detailed creation example with manual object handling.
Based on PDF 1.7 and 2.0 specifications, ensuring accurate document handling and compatibility, with references to official standards in the README.
Creating even simple PDFs requires manual management of objects, dictionaries, and streams, as seen in the lengthy 50+ line example just to add a single page with text.
Only handles decryption with empty passwords; password-protected PDFs require manual authentication, and the README notes this as a limitation with potentially incomplete implementation.
Keeps entire PDFs in memory until serialization, which the FAQ acknowledges can be inefficient for very large documents, posing scalability issues.
Requires Rust 1.85 or later for features like object streams, which may hinder adoption in projects with older toolchains or stable environment constraints.