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
| feature | default | adds |
|---|---|---|
javascript | off | the 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;javascriptpub use script::ScriptConfig;javascriptpub 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.
- script
javascript - The
boa-backedCascade— a document’s own scripts, run.
Structs§
- AnnotId
- Which annotation: a page and its index in that page’s raw
/Annotsarray. - Appearance
Update - One thing that changed, and what the caller may do about it.
- Commit
Outcome - What a commit did.
- Drag
Anchor - A mouse drag in progress.
- FieldId
- Which field a session is talking about: an index into the form’s field list.
- Field
Ref - A field, named the way a script would name it.
- Field
Writes - Values a calculation wants written to other fields.
- Focus
Change - What a focus change did, and what the caller must do about it.
- Focus
Ring - The focus ring for one page, in traversal order.
- Form
Session - 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.
- Page
Form - Everything one page contributes to routing.
- Permissions
- The document permission bits this crate consults.
- Place
- A caret position: after character
wordof linelineof sectionsection. - Popup
Geometry - Where an open dropdown sits and how tall its rows are.
- Popup
View - Everything a host needs to draw one open dropdown.
- Response
- What applying an event produced.
- Scroll
View - How far a scrollable control has scrolled, in rows.
- Session
Config - The switches a caller sets once and the engine reads.
- Widget
Info - 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.
- Focus
Target - Where keyboard input goes.
- Key
- A key on a keyboard, as an event reports it.
- Keystroke
Outcome - What the keystroke hook decided.
- Placement
- Which side of the widget the list opens on.
- Pointer
Trigger - Which of the six pointer and focus
/AAentries aCascade::pointercall is for. - Rotation
- A widget’s rotation, normalized to one of the four quadrants.
- TabOrder
- Which traversal order a page asks for.
- Update
Kind - What happened to an annotation.
Traits§
- Cascade
- The script hooks a commit passes through.
Functions§
- read_
page - Reads one page’s annotations.