Skip to content

[Bug]: Ticking the second box of a Yes/No check box pair saves the field as /V /Off #22183

Open

Description

@daniel-alexander4

Attach (recommended) or Link to PDF file

https://gist.githubusercontent.com/daniel-alexander4/f633aed6a17938d71bf74e6dbc80eea3/raw/452b9d93fb99bc8da8897a6349aa7c61b5b818d3/yes-no-pair.pdf

(For comparison: no-first.pdf is the same file with the two widgets listed in the other order.)


Web browser and its version

Google Chrome 155.0.8059.79

Operating system and its version

Linux Mint 22

PDF.js version

6.5.142 (online demo, build 6c5ef4c)

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No


Steps to reproduce the problem

  1. Open yes-no-pair.pdf in the online demo. It has one check box field, Answer, with two widgets: a "Yes" box on the left (ticked) and a "No" box on the right.
  2. Click the "No" box. "Yes" clears and "No" is ticked.
  3. Download the file.
  4. Look at the end of the downloaded file, e.g. tail -c 600 yes-no-pair.pdf.

What is the expected behavior?

The field's value is the state of the ticked box:

5 0 obj
<< /FT /Btn /T (Answer) /V /No /Kids [6 0 R 7 0 R]>>

That is what you get with no-first.pdf (same steps, the "No" widget listed first in /Kids and /Annots).

What went wrong?

5 0 obj
<< /FT /Btn /T (Answer) /V /Off /Kids [6 0 R 7 0 R]>>
...
7 0 obj
<< /Type /Annot /Subtype /Widget /Parent 5 0 R ... /AS /No ...>>

The "No" widget is saved with /AS /No, but the field's /V is /Off. Reopened in PDF.js, the "No" box still shows as ticked, because it reads /AS. Anything that reads the field's value (form data export, other PDF tools) sees no answer. Nothing looks wrong on screen, so there is no useful screenshot; the problem is only in the saved file.

Link to a viewer

No response

Additional context

_saveCheckbox calls setValue for the unticked widget too (_saveRadioButton only does so when the button is on). setValue writes the parent field's /V only for the first widget saved for that field. So whichever box is saved first decides the value, and when that is the unticked one, the field is saved as /Off.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions