GSoC/2024/StatusReports/PrathamGandhi
Forms/Javascript support improvement for Okular
Okular, the document viewer supports PDFs with forms. These forms often use Javascript to make forms more convenient for its users. However, as of today, the support for Javascript within Okular is quite lacking with large number of open bugs.
This project aims to improving the support for PDF forms in Okular as much as possible and make the feature set more consistent with Adobe Acrobat.
Work report
Below is the list of bug fixes and new features added during the GSoC 2024 period:
- Support for Acrobat Pre-Defined Methods:
Added support for key Acrobat methods, enabling correct processing of text fields:
- AFNumber_Keystroke
- AFSpecial_Keystroke
- AFMerge_Change
- AFTime_Keystroke
- AFDate_FormatEx
- AFDate_KeystrokeEx
- AFPercent_Format
- AFPercent_Keystroke
- Implementation of Event Properties:
- Implemented selStart and selEnd properties for event handling.
- Fixed the change event property to correctly handle Unicode characters.
- Fixed incorrect cursor position calculations during text entry.
- Mouse Events Support:
- Added support for generating event objects for MouseDown, MouseEnter, and MouseExit events. This improves form interactivity.
- Combobox Events Support:
- Implemented Keystroke, Validate, Calculate, and Format events for comboboxes, which were previously not triggered.
- Fixes for Form Field Event Execution:
- Earlier validation events were not being executed. Fixed this bug.
- Corrected the execution order of Keystroke, Validate, Calculate, and Format events, especially during undo/redo actions or when modified via JavaScript. These actions are now triggered only when a field value is committed, ensuring proper functionality and improved keyboard usability.
- Global Object implementation:
- A basic implementation of the global object was rolled out. This allows for document level use of a global object.
- Document-Level Event Support:
Implemented support for the following document-level events, improving overall document interaction:
- DocOpen
- DocWillClose
- DocWillPrint
- DocDidPrint
- DocWillSave
- DocDidSave
- SubmitForm Functionality:
- Added support for reading the SubmitForm action in Poppler. While Okular doesn’t yet implement form submission, this lays the foundation for future integration.
- Appearance Stream set support for Form Fields:
- Implemented a feature in Poppler allowing modification of appearance stream text in form fields without changing the underlying value, enhancing flexibility when working with form elements.
- Reset Form Functionality:
- Added a reset feature for forms in Okular, allowing users to clear fields or revert them to their default values.
- Form Field Enhancements:
- Implemented the 'value (getter), numItems, currentValueIndices properties, and the getItemAt function for FormFieldChoices.
- Adjusted the size of checkboxes and radio buttons, making them scalable during zoom.
- implemented refresh functions for RadioButton, ListEdit, and ComboEdit fields.
- Ability to revert an unacceptable field value back to the original committed value.
- Bug Fixes for Locale-Specific Calculations:
- Fixed incorrect numerical interpretation in form calculations when using different locales, improving the accuracy of form-based computations.
Links to Blogs and other writing
More details about every feature/bug fix and the relevant MR can be found on my blog posts: