Skip to main content

pdf_xfa/
lib.rs

1#![warn(missing_docs)]
2//! XFA engine — extraction, layout rendering, font resolution.
3//!
4//! This crate's public API is panic-free. Errors are returned as `Result<T, XfaError>`.
5//!
6//! ## JavaScript policy
7//!
8//! XFA forms that require JavaScript execution produce static-layout output by default.
9//! Full JavaScript execution requires the `xfa-js-sandboxed` feature flag.
10//!
11//! ## Module boundary notes
12//!
13//! The `*_bridge` modules (`appearance_bridge`, `font_bridge`, `image_bridge`,
14//! `paint_bridge`, `render_bridge`) are `pub` because integration tests and the
15//! `xfa-cli` debug command access their items directly by module path. These modules
16//! are considered **internal** (not part of the stable API surface) and may change
17//! without a semver bump. External callers should prefer the stable re-exports at
18//! the crate root. Items not listed in the `pub use` block below are not covered
19//! by stability guarantees.
20//!
21//! `javascript_policy` is similarly `pub` for cross-module visibility within the
22//! workspace. It is not intended as a public API for downstream crates.
23
24// Copyright (c) 2026 Innovation Trigger B.V.
25//
26// PDFluent is available under two licences, at your option: the GNU AGPLv3, or
27// the PDFluent Commercial Licence. See the LICENSE file in this repository --
28// that file travels with the copy you received, which a URL does not.
29
30pub mod appearance_bridge;
31/// Appearance stream generation for XFA form fields (internal bridge).
32pub mod barcode;
33pub mod classify;
34/// Faithful datasets/form packet writeback (surgical XML splice + PDF stream swap).
35mod datasets_writeback;
36/// Dynamic XFA script processing — binding, mode selection, and outcome reporting.
37pub mod dynamic;
38pub mod error;
39pub mod extract;
40pub mod flatten;
41pub mod flatten_cache;
42/// Env-gated flatten traceability (parse/bind/script/layout/paint/writer counts).
43mod flatten_trace;
44/// Font resolution, embedding, and metrics for the XFA flatten pipeline (internal bridge).
45pub mod font_bridge;
46/// Image embedding utilities for the XFA flatten pipeline (internal bridge).
47pub mod image_bridge;
48pub mod javascript_policy;
49pub mod js_runtime;
50pub mod merger;
51/// Paint command abstraction layer between layout and PDF rendering (internal bridge).
52pub mod paint_bridge;
53/// PDF content-stream rendering from layout DOM (internal bridge).
54pub mod render_bridge;
55/// Parse-once interactive fill session (Phase 1 SDK foundation).
56pub mod session;
57pub mod template_parser;
58
59pub use classify::{detect_xfa_type, detect_xfa_type_from_packets, XfaType};
60pub use dynamic::{
61    apply_interactive_commit, apply_interactive_commit_reported, apply_interactive_open,
62    apply_interactive_open_reported, DynamicScriptOutcome, FormDomMatchEntry, InstanceWriteEntry,
63    InteractiveOutcome, InteractiveTrigger, JsExecutionMode, OutputQuality, PresenceChange,
64    PresenceMutationEntry, ScriptLifecycleEntry, SkippedActivities, SomFailEntry, XfaScriptError,
65    XfaScriptErrorKind, XfaScriptReport, XfaScriptsSkipped,
66};
67pub use extract::{extract_embedded_fonts, validate_xfa_packets, PacketValidation};
68pub use flatten::{
69    compare_flatten_quality, flatten_xfa_to_pdf, flatten_xfa_to_pdf_with_layout_dump,
70    flatten_xfa_to_pdf_with_layout_dump_and_metadata, flatten_xfa_to_pdf_with_metadata,
71    flatten_xfa_to_pdf_with_policy, flatten_xfa_to_pdf_with_policy_and_metadata, is_pdf_encrypted,
72    validate_flattened_pdf, validate_text_completeness, FlattenMetadata, FlattenQualityMetrics,
73    FlattenValidation, LayoutDump, LayoutDumpEntry, TextValidation, XfaRenderingPolicy,
74};
75pub use js_runtime::{
76    activity_allowed_for_sandbox, activity_allowed_for_sandbox_with_gate,
77    presave_during_flatten_enabled, HostBindings, MutationLogEntry, NullRuntime, RuntimeMetadata,
78    RuntimeOutcome, SandboxError, XfaJsRuntime, DEFAULT_MEMORY_BUDGET_BYTES,
79    DEFAULT_TIME_BUDGET_MS, ENV_PRESAVE_DURING_FLATTEN, MAX_INSTANCES_PER_SUBFORM,
80    MAX_MUTATIONS_PER_DOC, MAX_RESOLVE_CALLS_PER_SCRIPT, MAX_RESOLVE_RESULTS,
81    MAX_SCRIPT_BODY_BYTES, MAX_SOM_DEPTH, MAX_VARIABLES_SCRIPT_BODY_BYTES,
82    SANDBOX_ACTIVITY_ALLOWLIST,
83};
84
85pub use formcalc_interpreter as formcalc;
86pub use xfa_dom_resolver as dom_resolver;
87pub use xfa_json as json;
88pub use xfa_layout_engine as layout;