ngx-extended-pdf-viewer icon indicating copy to clipboard operation
ngx-extended-pdf-viewer copied to clipboard

Checkbox selection missing after loading PDF

Open artstalker opened this issue 11 months ago • 10 comments

Link to PDF file here: Check box issue.pdf

Steps to reproduce:

  1. Load PDF file Actual result: The checkboxes are selected

image

Expected results:

If you open PDF in any other PDF viewer, the No checkboxes are selected image

The issue is not reproducible in https://mozilla.github.io/pdf.js/web/viewer.html

artstalker avatar Mar 08 '24 20:03 artstalker

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?

stephanrauh avatar Mar 08 '24 21:03 stephanrauh

No, it is not intended.

artstalker avatar Mar 08 '24 22:03 artstalker

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.

stephanrauh avatar Mar 08 '24 22:03 stephanrauh

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

artstalker avatar Mar 08 '24 22:03 artstalker

Disregard my last comment. It is actually working in https://pdfviewer.net/extended-pdf-viewer/

artstalker avatar Mar 08 '24 22:03 artstalker

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...

stephanrauh avatar Mar 09 '24 17:03 stephanrauh

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. image

But can't be displayed in ngx-extended-pdf-viewer image

artstalker avatar Mar 11 '24 21:03 artstalker

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.

stephanrauh avatar Mar 11 '24 22:03 stephanrauh

Do you have any plans to fix it in the near future?

artstalker avatar Mar 12 '24 16:03 artstalker

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.

stephanrauh avatar Mar 12 '24 21:03 stephanrauh

Hi,

Any updates on this ticket?

Here is another PDF with a similar issue.

Is it the same problem?

ACORD 0125 2016-03r1 Acroform (64).pdf

artstalker avatar Apr 09 '24 22:04 artstalker

Thanks for reminding me. For some reason, I'm always distracted from solving your ticket each time I try.

stephanrauh avatar Apr 10 '24 19:04 stephanrauh

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.

artstalker avatar Apr 10 '24 21:04 artstalker

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.

stephanrauh avatar Apr 13 '24 14:04 stephanrauh

Version 20.0.0-alpha.0 has landed.

stephanrauh avatar Apr 13 '24 21:04 stephanrauh