acroform-rs 
Read, alter and write PDF files with AcroForm support.
This repository contains a fork of pdf-rs (published as acroform-pdf) with added high-level AcroForm (PDF form) manipulation capabilities.
Features
- Low-level PDF manipulation via the
acroform-pdfcrate (fork of pdf-rs with bug fixes) - High-level form filling via the new
acroformcrate - Simple three-step API: load, list fields, fill and save
- Type-safe field values
- Minimal dependencies and auditable code (KISS principle)
Usage
Add to your Cargo.toml:
[]
= "0.0.3"
For low-level PDF manipulation:
[]
= "0.9.0" # Low-level PDF library
= "0.0.3" # High-level form filling
Basic Example
use ;
use HashMap;
Architecture
This repository contains two main publishable crates:
acroform-pdf(inpdf/directory) - Fork of pdf-rs with bug fixes, provides low-level PDF parsing and writingacroform(inacroform/directory) - NEW high-level API for form manipulation (depends onacroform-pdf)
This separation allows:
- Publishing both crates to crates.io
- Easy merging of upstream pdf-rs updates
- Clean separation between forked and new code
- Use of either low-level or high-level APIs as needed
Examples
Run the simple form filling example:
See more examples in examples/src/bin/:
simple_fill.rs- High-level form filling APIform.rs- Low-level form manipulation example
Testing
Run tests:
Documentation
See designs/PLAN.md for detailed architecture and design decisions.
Limitations
- Non-incremental PDF writing only (full rewrite)
- No appearance stream generation (relies on viewer's
/NeedAppearancessupport) - No digital signature support
- No XFA form support
Contributing
Modifying and writing PDFs is still experimental.
One easy way you can contribute is to add different PDF files to tests/files and see if they pass the tests (cargo test).
Feel free to contribute with ideas, issues or code! Please join us on Zulip if you have any questions or problems.
Workspace
This repository uses a Cargo Workspace. The workspace contains:
acroform-pdf- Low-level PDF library (fork of pdf-rs)acroform-pdf-derive- Derive macros for acroform-pdfacroform- High-level form filling APIexamples- Example applications
To build specific crates:
Examples
Examples are located in pdf/examples/ and examples/src/bin/ and can be executed using:
cargo run --example {content,metadata,names,read,text} -- <files/{choose a pdf}>
cargo run --bin {simple_fill,form} -- <input.pdf> [output.pdf]
Renderer and Viewer
A library for rendering PDFs via Pathfinder and minimal viewer can be found here.
Inspect
There is a tool for visualizing a PDF file as an interactive hierarchy of primitives at inspect-prim. Just clone and cargo run.