Skip to content

A select's selected option renders as the first option in poppler #58

Description

@jakejackson1

Summary

A <select> with a selected option, rendered with useActiveForms, shows its first option in poppler rather than the selected one. mPDF writes the field correctly as far as I can tell: /Opt holds export-and-label pairs and /V and /DV hold the export value of the selected option. What needs settling is whether /V should hold the export value or the label, since poppler evidently matches it against the label, and what Acrobat and Chrome show.

Found while building the forms snapshot document for #38, which renders a select in each of its two blocks; the rasters show "First option" although the second is marked selected. Same on gravitypdf.

Try it

$mpdf = new \Mpdf\Mpdf();
$mpdf->useActiveForms = true;
$mpdf->WriteHTML('<select name="s">
  <option value="1">First option</option>
  <option value="2" selected="selected">Second option</option>
</select>');
$mpdf->Output('select.pdf', 'F');

The field object carries /Opt [ [(1) (First option)] [(2) (Second option)] ] /V (2) /DV (2). pdftoppm renders "First option" in the box.

Where to look

  • ISO 32000-1 §12.7.4.4 on choice fields, for whether /V is the export value or the display string when /Opt uses pairs.
  • Form::_putform_ch() writes /V from the option's value attribute.
  • Acrobat and Chrome, for what they display for the same file; if both show the selected option, this is a poppler difference and the issue can be closed with a note.

Test plan

  • A unit case on the emitted document asserting /V for a selected option, in whichever form the spec settles on, and one for a select with no selected option.
  • The forms snapshot document from Make page-break-inside: avoid dependable #38 re-rendered; its two selects should read "Second option, selected" in the raster if the fix reaches poppler's matching.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions