Skip to main content

Crate pdfrum_form

Crate pdfrum_form 

Source
Expand description

§pdfrum-form

Interactive forms as a live session (ISO 32000-1 §12.7): events in, appearance updates out. A click, a keystroke or a focus change goes in; what changed on screen comes back. Nothing is rasterized here, and the field appearance streams themselves are generated in pdfrum-doc.

use pdfrum_form::{FormSession, NoScripts};

let session = FormSession::new();
assert!(session.fields.is_empty());
let _cascade = NoScripts;

FormSession holds live field state across events; route::apply routes one Event into it and returns a Response saying what changed, and the caller paints. That split is why this crate has no window and no widget chrome — an embedder owns the pixels, and the same session drives a GUI, a headless fill and a test.

A focused field draws from live editor state; an unfocused one falls back to a generated appearance. Those are two different sources for the same rectangle, and the switch is what makes a caret and a partial selection possible at all — a generated appearance stream has no notion of either. Coordinates are page space, y-up from the crop-box origin, not device pixels.

Two identifiers, and they are not interchangeable. FieldId is page-local, which is what a hit test on one page produces. FieldRef::index is the document-wide name a script uses, because a /AA script naming a field means the field anywhere in the document. A form whose fields span pages needs both.

§Features

featuredefaultadds
javascriptoffthe boa-backed Cascade — the document’s own /AA scripts, actually run

With javascript off, boa_engine is not in the dependency tree and a document’s scripts are data: NoScripts is the Cascade that runs nothing, and every other behaviour of the session is unchanged.

Part of pdfrum. #![forbid(unsafe_code)].

MIT OR Apache-2.0

Re-exports§

pub use edit::PlaceExt;
pub use edit::Range;
pub use edit::Selection;
pub use edit::UndoItem;
pub use edit::UndoStack;
pub use field::ChoiceConfig;
pub use field::ChoiceState;
pub use field::FieldState;
pub use field::TextConfig;
pub use field::TextState;
pub use field::ToggleState;
pub use route::Context;
pub use route::appearances_on_page;
pub use route::apply;
pub use route::choose;
pub use route::close_popup;
pub use route::focus_field;
pub use route::focus_of;
pub use route::kill_focus;
pub use route::popup_view;
pub use route::replace_selection;
pub use route::scroll_view;
pub use route::scroll_views_on_page;
pub use script::ScriptCascade;javascript
pub use script::ScriptConfig;javascript
pub use script::TranscriptLine;javascript

Modules§

edit
The edit control: what interacting with a text field adds to the layout engine.
field
Per-field interaction state, and the configuration read once from the file.
route
Applying one event to a session: the function the whole crate exists to provide.
scriptjavascript
The boa-backed Cascade — a document’s own scripts, run.

Structs§

AnnotId
Which annotation: a page and its index in that page’s raw /Annots array.
AppearanceUpdate
One thing that changed, and what the caller may do about it.
CommitOutcome
What a commit did.
DragAnchor
A mouse drag in progress.
FieldId
Which field a session is talking about: an index into the form’s field list.
FieldRef
A field, named the way a script would name it.
FieldWrites
Values a calculation wants written to other fields.
FocusChange
What a focus change did, and what the caller must do about it.
FocusRing
The focus ring for one page, in traversal order.
FormSession
One interaction session over one document.
Keystroke
A keystroke offered to the keystroke hook.
Modifiers
The modifier bits carried by an event (FWL_EVENTFLAG).
NoScripts
The script-free cascade, and this crate’s only implementation.
PageForm
Everything one page contributes to routing.
Permissions
The document permission bits this crate consults.
Place
A caret position: after character word of line line of section section.
PopupGeometry
Where an open dropdown sits and how tall its rows are.
PopupView
Everything a host needs to draw one open dropdown.
Response
What applying an event produced.
ScrollView
How far a scrollable control has scrolled, in rows.
SessionConfig
The switches a caller sets once and the engine reads.
WidgetInfo
One widget annotation, read far enough to build its field’s state.

Enums§

Button
Which mouse button an event came from.
Error
What went wrong.
Event
One input event.
FocusTarget
Where keyboard input goes.
Key
A key on a keyboard, as an event reports it.
KeystrokeOutcome
What the keystroke hook decided.
Placement
Which side of the widget the list opens on.
PointerTrigger
Which of the six pointer and focus /AA entries a Cascade::pointer call is for.
Rotation
A widget’s rotation, normalized to one of the four quadrants.
TabOrder
Which traversal order a page asks for.
UpdateKind
What happened to an annotation.

Traits§

Cascade
The script hooks a commit passes through.

Functions§

read_page
Reads one page’s annotations.