pdf-rs is an open-source Rust crate for parsing and reading PDF files. It handles text extraction and document structure traversal well. It is read-only by design: there is no write API, no form filling, no PDF/A output, and no digital signatures. PDFluent covers reading, writing, form processing, validation, and signing.
use pdfluent::PdfDocument;
fn main() -> pdfluent::Result<()> {
let mut doc = PdfDocument::open("application.pdf")?;
// Read
let text = doc.page(1)?.text()?;
println!("{}", text);
// Write form fields
let mut form = doc.form_mut();
form.set_text("applicant_name", "Jane Smith")?;
form.set_text("date", "2024-04-14")?;
// Sign
let signer = pdfluent::Pkcs12Signer::from_pfx_file("cert.p12", "password")?;
doc.sign(&signer, pdfluent::SignOptions::new())?;
// Validate PDF/A-2b before saving
let report = doc.validate_pdfa(pdfluent::PdfAProfile::A2b)?;
if !report.is_compliant() {
eprintln!("Validation issues: {:?}", report.violations);
}
doc.save("application_signed.pdf")?;
Ok(())
}use pdf::file::FileOptions;
use pdf::object::*;
fn main() {
// pdf-rs opens PDFs for reading only
let file = FileOptions::cached().open("application.pdf").unwrap();
// Traverse pages and extract text
for page in file.pages() {
let page = page.unwrap();
// Content stream traversal - no high-level text API
if let Some(content) = page.contents.as_ref() {
println!("{:?}", content);
}
}
// pdf-rs CANNOT write PDF files
// pdf-rs CANNOT fill form fields
// pdf-rs CANNOT add digital signatures
// pdf-rs CANNOT validate or produce PDF/A
// pdf-rs CANNOT flatten XFA forms
}| Feature | PDFluent | pdf-rs (Rust) |
|---|---|---|
| PDF parsing / reading | ||
| Text extraction (high-level API) | Low-level only | |
| PDF writing | ||
| AcroForm filling | ||
| XFA forms | ||
| Digital signatures (PAdES) | ||
| PDF/A validation | ||
| WASM target | Partial |
Choose PDFluent if you need to write, modify, sign, or validate PDFs — not just read them. Any production document workflow (filling forms, signing, archiving) requires write capabilities that pdf-rs does not have.
pdf-rs is fine for a read-only parser in an open source Rust project — extracting text from PDFs, reading metadata, or inspecting document structure without modification.
If you only need to read and parse PDF structure in a Rust project and do not need to write anything back, pdf-rs is a lightweight option. If your use case involves any write operation, form filling, signing, or validation, you need PDFluent.
Free under the AGPLv3, or a commercial licence if you would rather not publish your own source.