Skip to main content

Crate pdfluent_forms

Crate pdfluent_forms 

Source
Expand description

AcroForm engine for PDF interactive forms.

Parses AcroForm field dictionaries from a pdf_syntax::Pdf into an in-memory FieldTree — an arena-based tree that mirrors the AcroForm parent/child hierarchy. Supports field value read/write, appearance generation, and form flattening.

§Quick Start

use std::sync::Arc;
use pdf_syntax::Pdf;
use pdfluent_forms::{parse_acroform, FieldType, FieldValue};

let data = Arc::new(std::fs::read("form.pdf").unwrap());
let pdf = Pdf::new(data).unwrap();

let tree = parse_acroform(&pdf).expect("no AcroForm found");

for id in tree.terminal_fields() {
    let name  = tree.fully_qualified_name(id);
    let ftype = tree.effective_field_type(id);
    let value = tree.effective_value(id);
    println!("[{ftype:?}] {name} = {value:?}");
}

// Find a field by name and inspect its properties.
if let Some(id) = tree.find_by_name("Address.Street") {
    let node = tree.get(id);
    println!("max_len = {:?}", node.max_len);
}

§Key Types

TypeDescription
FieldTreeArena of all AcroForm field nodes
FieldNodeA single field or group (partial name, type, value, …)
FieldIdOpaque index into the arena
FieldTypeText, Button, Choice, Signature
FieldValueText string or array of selected strings (choice fields)
FieldFlagsBit-field from PDF /Ff — read-only, required, multiline, …
FormAccessTrait used by language bindings for unified AcroForm / XFA access

§Entry Point

parse_acroform is the single parser entry point. It returns None when the document has no /AcroForm dictionary.

Re-exports§

pub use facade::DocumentOps;
pub use facade::FormAccess;
pub use facade::FormError;
pub use facade::FormKind;
pub use flags::FieldFlags;
pub use parse::parse_acroform;
pub use tree::FieldId;
pub use tree::FieldNode;
pub use tree::FieldTree;
pub use tree::FieldType;
pub use tree::FieldValue;
pub use tree::Quadding;

Modules§

actions
Field validation, calculation, and format script hooks (B.7).
appearance
Default Appearance (DA) parsing and appearance stream generation (B.6).
button
Checkbox, radio button, and push button implementation (B.3 + B.5).
choice
Dropdown and listbox implementation (B.4).
facade
Unified form access facade for language bindings.
flags
Field flags (/Ff) bitfield wrapper (B.1).
flatten
Form flattening: convert interactive fields to static content (B.8).
parse
AcroForm dictionary parser (B.1).
text
Text field implementation (B.2).
tree
Arena-based field tree for AcroForm fields (B.1).