Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkmarks are not shown in Print Preview and are not printed in pdf #12233

Closed
bogdanmaris opened this issue Aug 18, 2020 · 3 comments · Fixed by #12263
Closed

Checkmarks are not shown in Print Preview and are not printed in pdf #12233

bogdanmaris opened this issue Aug 18, 2020 · 3 comments · Fixed by #12263

Comments

@bogdanmaris
Copy link

bogdanmaris commented Aug 18, 2020

Affected versions

  • 81.0a1 (2020-08-18)

Affected platforms

  • Windows 10 64bit
  • macOS 10.15
  • Ubuntu 18.04 64bit

Steps to reproduce
pdfjs.renderInteractiveForms - true

  1. Launch Firefox
  2. Access a PDF form with fillable content (eg: OoPdfFormExample.pdf)
  3. Tick some checkboxes
  4. Enter some text and some numbers
  5. Enter Print Preview
  6. Print to pdf

Expected result

  • All the input is saved in Print Preview as well and printed in PDF.

Actual result

  • Checkmarks are not saved in Print Preview and are not printed on file.

Additional notes

  • S2 as suggested severity, due to data loss.
@timvandermeij timvandermeij added viewer form-acroform Gecko 81 Tracking work planned for Form Fill in Shirley 81 release labels Aug 18, 2020
@bogdanmaris
Copy link
Author

Hmm, this looks like it has something to do with that particular PDF, using https://www.irs.gov/pub/irs-pdf/f1040.pdf the checkmarks are saved both in print preview and printed to pdf

@timvandermeij
Copy link
Contributor

I have found the cause and am working on a fix. The problem is that the value given to _renderText is undefined, while it should always be a string. It works if all fields are explicitly changed, but not if some are not changed. This is a strange edge case, but thanks for finding it!

@timvandermeij timvandermeij self-assigned this Aug 18, 2020
@timvandermeij
Copy link
Contributor

timvandermeij commented Aug 18, 2020

The choice widgets in this PDF file are problematic. I have identified two issues in the choice widgets code:

  • For the gender and color boxes, the field value is encoded (contains the UTF-16 BOM and null characters), and because the display value doesn't we never select the correct entry not put anything in the annotation storage, leading to an undefined text value when printing/saving. I believe this should be solved by using the export value instead of the display value since the display value is not meant to be used for anything but display in the viewer and the export value is meant to be saved. This works for the viewer, but the printed value now contains the UTF-16 BOM in rendering, so I'm not sure yet how to solve that...
  • For the country box, the field value is an empty string. This is because it's actually a combobox (dropdown with a text field to enter a custom value) and we don't support that yet for rendering, which is tracked in [LaTeX][forms][hyperref] ChoiceMenu combo not editable #10669. To make printing/saving work we should make sure to always put the field value in the annotation storage. This is the only correct way because comboboxes can have a value that is not available in the options. For now we should most likely just insert the first value of the array since we don't support list box printing/saving yet (tracked in Implement printing/saving support for listboxes #12189).

@timvandermeij timvandermeij removed the Gecko 81 Tracking work planned for Form Fill in Shirley 81 release label Aug 21, 2020
timvandermeij added a commit to timvandermeij/pdf.js that referenced this issue Aug 22, 2020
…ption selection

The export value is used when the document is saved, so it should also
be used when the document is opened to determine which choice widget
option is selected. The display value is, as the name implies, only to
be used for viewer display purposes and not for other logic.

This makes sure that in the document from mozilla#12233 the "Favourite colour"
choice widget is correctly initialized with "Red" instead of "Black"
because the field value is equal to the export value (always the case),
but not the display value (not always the case). Moreover, saving now
also correctly uses the export value and not the display value.
timvandermeij added a commit to timvandermeij/pdf.js that referenced this issue Aug 22, 2020
The down appearance (`D`) is optional and not available in the document
from mozilla#12233, so the checkboxes are never saved/printed as checked
because the checked appearance is based on the export value that is
missing because the `D` entry is not available.

Instead, we should use the normal appearance (`N`) since that one is
required and therefore always available.
timvandermeij added a commit to timvandermeij/pdf.js that referenced this issue Aug 22, 2020
In addition to the unit tests these reference tests make sure that this
document, that triggered some edge cases in our code, can be rendered
and printed successfully now.
timvandermeij added a commit to timvandermeij/pdf.js that referenced this issue Aug 22, 2020
The down appearance (`D`) is optional and not available in the document
from mozilla#12233, so the checkboxes are never saved/printed as checked
because the checked appearance is based on the export value that is
missing because the `D` entry is not available.

Instead, we should use the normal appearance (`N`) since that one is
required and therefore always available.

Finally, the off appearance is optional according to section 12.7.4.2.3
of the specification, so that needs to be taken into account to match
the specification and to fix reference test failures for the
`annotation-button-widget-print` test. That is a file that doesn't
specify an off appearance in the normal appearance dictionary.
timvandermeij added a commit to timvandermeij/pdf.js that referenced this issue Aug 22, 2020
In addition to the unit tests these reference tests make sure that this
document, that triggered some edge cases in our code, can be rendered
and printed successfully now.
timvandermeij added a commit to timvandermeij/pdf.js that referenced this issue Aug 23, 2020
The down appearance (`D`) is optional and not available in the document
from mozilla#12233, so the checkboxes are never saved/printed as checked
because the checked appearance is based on the export value that is
missing because the `D` entry is not available.

Instead, we should use the normal appearance (`N`) since that one is
required and therefore always available.

Finally, the /Off appearance is optional according to section 12.7.4.2.3
of the specification, so that needs to be taken into account to match
the specification and to fix reference test failures for the
`annotation-button-widget-print` test. That is a file that doesn't
specify an /Off appearance in the normal appearance dictionary.
timvandermeij added a commit to timvandermeij/pdf.js that referenced this issue Aug 23, 2020
In addition to the unit tests these reference tests make sure that this
document, that triggered some edge cases in our code, can be rendered
and printed successfully now.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 9, 2023
When printing the pdf in mozilla#12233 in Acrobat, we can see that the combo for country
is empty: it's because the V entry doesn't have to be one of the options.
calixteman added a commit to calixteman/pdf.js that referenced this issue Feb 9, 2023
When printing the pdf in mozilla#12233 in Acrobat, we can see that the combo for country
is empty: it's because the V entry doesn't have to be one of the options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants