Skip to content

Feature/form#537

Open
bobsingor wants to merge 26 commits intomainfrom
feature/form
Open

Feature/form#537
bobsingor wants to merge 26 commits intomainfrom
feature/form

Conversation

@bobsingor
Copy link
Contributor

No description provided.

Introduce a new setFormFieldState API to PdfEngine/IPdfiumExecutor and Pdfium orchestration. The change wires the method through the orchestrator, remote executor, webworker engine and runner, and implements the behavior in PdfiumNative using PDFium form APIs to apply full widget field snapshots (text, checkbox/radio, combobox/listbox) with proper focus, selection, option selection, error handling and memory management. Also update model types and generated PDFium function bindings to support the new flow, and adjust form plugin code to work with the PdfWidgetAnnoField snapshot.
Add support for PDF form widget annotations: create form fields for WIDGET annotations, populate text-field-specific properties (default appearance, border style, MK border/background colors, and form field flags), and generate form-field appearance streams. Expose helpers to set/get MK colors and a dedicated addTextFieldContent routine. Use a FormFill environment when reading annotations (single page and batch) and pass the form handle into widget readers. Update PDFium JS bindings to include form and MK-related functions (CreateFormField, GenerateFormFieldAP, EPDFAnnot_Set/GetMKColor, etc.). Extend models with optional borderColor/backgroundColor and a PdfAnnotationOf helper type. Also include new plugin-form files and viewer icon assets to support form UI. These changes enable better round-trip handling and rendering of interactive form fields.
Unify annotation color/width properties and switch sidebar property mapping to use tools. Models: PdfWidgetAnnoObject renamed borderColor->strokeColor and backgroundColor->color, added strokeWidth. Pdfium engine now reads/writes strokeColor, color and strokeWidth. Plugin-form and form UI updated to use strokeColor/color/strokeWidth (defaults and rendering). Plugin-annotation tools gained optional labelKey for i18n and many tools updated with labelKey values. The property schema was refactored from subtype-based ANNOTATION_PROPERTIES to TOOL_PROPERTIES keyed by tool id; DynamicSidebar and AnnotationSidebar now resolve properties and titles via tool matching. Added widget-edit UI: icon, sidebar component, UI schema panel, and a command to toggle widget edit (with update to command visibility/behavior). Breaking change: code referencing borderColor/backgroundColor should be migrated to strokeColor/color and may need to handle strokeWidth.
Implement end-to-end checkbox (form field) support: handle CHECKBOX cases when creating/updating widget annotations, add addCheckboxContent to configure border, MK colors, flags and field name, and set form field value for generic fields. Ensure appearances are regenerated using EPDFAnnot_GenerateFormFieldAP in appropriate code paths and call it after forcing focus kill. Add clearMKColor helper and clear MK colors when none provided. Update pdfium vendor bindings/binaries to include new EPDFAnnot and ClearMKColor entries. Also add plugin-form checkbox handler and form-checkbox component and update form renderers/tools and viewer snippet property schema/commands to support checkbox fields.
Add a regenerateWidgetAppearances API and implementation across the engine layers so form widget appearance streams can be regenerated on demand. Changes include:

- Models: expose PdfEngine.regenerateWidgetAppearances and IPdfiumExecutor signature.
- Orchestrator/Worker/Remote: forward the new request and enqueue/proxy worker tasks.
- Pdfium native executor: implement regeneration by calling EPDFAnnot_GenerateFormFieldAP for matching annotation NMs and regenerate page content when any were updated.
- PDFium interop & fixes: handle unknown/non-standard fonts by falling back to Helvetica where needed, adjust checkbox/radiobutton checked detection to use the annotation "AS" state, and small cleanup comments/logic tweaks.
- Bump pdfium submodule and update autogenerated vendor functions (formatting/typing changes).

This enables programmatic refresh of widget appearances after form changes and fixes font/checkbox handling to avoid write failures or incorrect checked state detection.
Remove cached form-fill state from PageContext and introduce withFormHandle to create a fresh form-fill info/handle for each operation. Update engine call sites to use the ephemeral handle (or pageCtx.withFormHandle) and adjust helper signatures (e.g. addTextFieldContent, addCheckboxContent) to accept a formHandle. Consolidates resource management and cleanup (FORM_OnAfter/BeforeClose, PDFiumExt_Exit/Close) into well-scoped try/finally blocks, fixes stale-state risks, and ensures form rendering and annotation reads/writes use a safe, short-lived form-fill environment. Changes affect packages/engines/src/lib/pdfium/cache.ts and packages/engines/src/lib/pdfium/engine.ts.
Implement choice field handling for COMBOBOX and LISTBOX across the stack. Added addChoiceFieldContent() in the Pdfium engine to set appearance (DA), border (BS), MK colors, form field flags (preserving Combo bit 17), field name, options (/Opt array) and default value (/V) with proper WASM memory management. Wire up creation & rendering branches and selection handling (FORM_SetIndexSelected / multi-select list handling). Updated generated PDFium function bindings and bumped the pdfium submodule commit. Also add plugin-form handlers and components (combobox/listbox) and update form renderers, tools and snippet sidebar/commands to support these new field types.
@vercel
Copy link

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
embed-pdf-snippet Ready Ready Preview, Comment Mar 21, 2026 10:24pm
embed-pdf-viewer-react-mui Ready Ready Preview, Comment Mar 21, 2026 10:24pm
embed-pdf-viewer-svelte-tailwind Ready Ready Preview, Comment Mar 21, 2026 10:24pm
embed-pdf-viewer-vue-vuetify Error Error Mar 21, 2026 10:24pm
embed-pdf-website Error Error Mar 21, 2026 10:24pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant