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/// Appearance stream generation for XFA form fields (internal bridge).
25pub mod appearance_bridge;
26pub mod classify;
27/// Dynamic XFA script processing — binding, mode selection, and outcome reporting.
28pub mod dynamic;
29pub mod error;
30pub mod extract;
31pub mod flatten;
32/// Env-gated flatten traceability (parse/bind/script/layout/paint/writer counts).
33mod flatten_trace;
34/// Font resolution, embedding, and metrics for the XFA flatten pipeline (internal bridge).
35pub mod font_bridge;
36/// Image embedding utilities for the XFA flatten pipeline (internal bridge).
37pub mod image_bridge;
38pub mod javascript_policy;
39pub mod js_runtime;
40pub mod merger;
41/// Paint command abstraction layer between layout and PDF rendering (internal bridge).
42pub mod paint_bridge;
43/// PDF content-stream rendering from layout DOM (internal bridge).
44pub mod render_bridge;
45pub mod template_parser;
46
47pub use classify::{detect_xfa_type, detect_xfa_type_from_packets, XfaType};
48pub use dynamic::{
49    DynamicScriptOutcome, FormDomMatchEntry, InstanceWriteEntry, JsExecutionMode, OutputQuality,
50    PresenceMutationEntry, ScriptLifecycleEntry, SkippedActivities, SomFailEntry,
51};
52pub use extract::{extract_embedded_fonts, validate_xfa_packets, PacketValidation};
53pub use flatten::{
54    compare_flatten_quality, flatten_xfa_to_pdf, flatten_xfa_to_pdf_with_layout_dump,
55    flatten_xfa_to_pdf_with_layout_dump_and_metadata, flatten_xfa_to_pdf_with_metadata,
56    flatten_xfa_to_pdf_with_policy, flatten_xfa_to_pdf_with_policy_and_metadata, is_pdf_encrypted,
57    validate_flattened_pdf, validate_text_completeness, FlattenMetadata, FlattenQualityMetrics,
58    FlattenValidation, LayoutDump, LayoutDumpEntry, TextValidation, XfaRenderingPolicy,
59};
60pub use js_runtime::{
61    activity_allowed_for_sandbox, activity_allowed_for_sandbox_with_gate,
62    presave_during_flatten_enabled, HostBindings, MutationLogEntry, NullRuntime, RuntimeMetadata,
63    RuntimeOutcome, SandboxError, XfaJsRuntime, DEFAULT_MEMORY_BUDGET_BYTES,
64    DEFAULT_TIME_BUDGET_MS, ENV_PRESAVE_DURING_FLATTEN, MAX_INSTANCES_PER_SUBFORM,
65    MAX_MUTATIONS_PER_DOC, MAX_RESOLVE_CALLS_PER_SCRIPT, MAX_RESOLVE_RESULTS,
66    MAX_SCRIPT_BODY_BYTES, MAX_SOM_DEPTH, MAX_VARIABLES_SCRIPT_BODY_BYTES,
67    SANDBOX_ACTIVITY_ALLOWLIST,
68};
69
70pub use formcalc_interpreter as formcalc;
71pub use xfa_dom_resolver as dom_resolver;
72pub use xfa_json as json;
73pub use xfa_layout_engine as layout;