ngx-extended-pdf-viewer
ngx-extended-pdf-viewer copied to clipboard
Checkbox selection missing after loading PDF
Link to PDF file here: Check box issue.pdf
Steps to reproduce:
- Load PDF file Actual result: The checkboxes are selected
Expected results:
If you open PDF in any other PDF viewer, the No checkboxes are selected
The issue is not reproducible in https://mozilla.github.io/pdf.js/web/viewer.html
Slightly off-topic: I've opened the PDF in Firefox, Chrome, and the native PDF viewer of MacOS. Neither application allows me to unselect the "no" checkboxes. Is this intended?
No, it is not intended.
Well, it happens on three different PDF viewers, so maybe something is wrong with your PDF file. That's just a gut feeling: I haven't analyzed your bug yet, so it's merely an educated guess.
I got many different PDFs that are not working. Here is another example where you can select/unselect checkboxes in the different viewers including PDF.js. 23-24 Acord 28 Certificate_03-07-24_Template.pdf
Disregard my last comment. It is actually working in https://pdfviewer.net/extended-pdf-viewer/
Already forgotten. :) Supporting PDF checkboxes is always in pain in the... well, you know where. I should've investigated the topic before starting to implement the feature. In PDF country, checkboxes can be radio buttons and vice versa, and usually they don't map to true and false, but to arbitrary strings. I didn't know at the time, and now it's difficult to get closer to the PDF spec without breaking existing applications. Many of them rely on my mistakes...
It seems radio buttons can not be rendered as selected in the editor.
I made a simple example with a radiobutton control. Radiobutton issue (2).pdf
The selection is rendered in all PDF viewers.
But can't be displayed in ngx-extended-pdf-viewer
Oops - this lines are the culprit, and probably they don't make sense: https://github.com/stephanrauh/pdf.js/blob/ce8de5f97da84afe726d35bb26b320c410253501/src/display/annotation_layer.js#L1702-L1706
My code assumes that a checkbox can either be true or false. But the widget at hand is a radiobutton, so the assumption is doomed to fail. My code detects that your radio button is selected, so it decides it's value is true
. A short time later, it compare true
with the real value ("Choice1"
). This evaluates to false, so the radio button is unselected.
Do you have any plans to fix it in the near future?
Yes. At the moment I try to figure out which problems I'm going to cause by the bug fix. I hope the bug is so bad nobody relies on it. Once I've made up my mind, fixing the bug should be easy.
Hi,
Any updates on this ticket?
Here is another PDF with a similar issue.
Is it the same problem?
Thanks for reminding me. For some reason, I'm always distracted from solving your ticket each time I try.
Please have a look if example I attached above is the same problem. I don't have an editor where I can view list of possible values for this PDF.
Yes, all the document are affected by this bug. I've solved it now. The bugfix is landing with version 20 soon.
Fixing this bug is - strictly speaking - a breaking change, so I'll increase the major version number and start with alpha version for a short time.
Version 20.0.0-alpha.0 has landed.