Jump to content

GSoC/2024/StatusReports/PrathamGandhi

From KDE Community Wiki

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:

  1. AFNumber_Keystroke
  2. AFSpecial_Keystroke
  3. AFMerge_Change
  4. AFTime_Keystroke
  5. AFDate_FormatEx
  6. AFDate_KeystrokeEx
  7. AFPercent_Format
  8. AFPercent_Keystroke
  • Implementation of Event Properties:
  1. Implemented selStart and selEnd properties for event handling.
  2. Fixed the change event property to correctly handle Unicode characters.
  3. Fixed incorrect cursor position calculations during text entry.
  • Mouse Events Support:
  1. Added support for generating event objects for MouseDown, MouseEnter, and MouseExit events. This improves form interactivity.
  • Combobox Events Support:
  1. Implemented Keystroke, Validate, Calculate, and Format events for comboboxes, which were previously not triggered.
  • Fixes for Form Field Event Execution:
  1. Earlier validation events were not being executed. Fixed this bug.
  2. 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:
  1. 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:

  1. DocOpen
  2. DocWillClose
  3. DocWillPrint
  4. DocDidPrint
  5. DocWillSave
  6. DocDidSave
  • SubmitForm Functionality:
  1. 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:
  1. 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:
  1. Added a reset feature for forms in Okular, allowing users to clear fields or revert them to their default values.
  • Form Field Enhancements:
  1. Implemented the 'value (getter), numItems, currentValueIndices properties, and the getItemAt function for FormFieldChoices.
  2. Adjusted the size of checkboxes and radio buttons, making them scalable during zoom.
  3. implemented refresh functions for RadioButton, ListEdit, and ComboEdit fields.
  4. Ability to revert an unacceptable field value back to the original committed value.
  • Bug Fixes for Locale-Specific Calculations:
  1. 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: