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

Render not displayed annotations in using normal appearance when printing #12395

Merged
merged 1 commit into from
Oct 27, 2020

Conversation

calixteman
Copy link
Contributor

A pdf with several pages containing some text or checked radio/checkbox not on page 1/2 were not printed.
Since they were not rendered in annotation_layer, then the annotationStorage has no entries for such widget.
So the goal of the patch is to fix that in using normalAppearance when the annotationStorage doesn't contain the widget id.

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a PDF file to test this with? Even though the unit tests cover the cases and adding a reference test is not really possible, it would be good for me to verify this in the viewer itself.

@calixteman
Copy link
Contributor Author

Do you have a PDF file to test this with? Even though the unit tests cover the cases and adding a reference test is not really possible, it would be good for me to verify this in the viewer itself.

https://www.canada.ca/content/dam/ircc/migration/ircc/english/passport/forms/pdf/pptc155.pdf

Save something on page 3 and reopen the newly created file and print.

@Snuffleupagus
Copy link
Collaborator

[...] and adding a reference test is not really possible,

Why is that though, since based on the description in #12395 (comment) I'd sort of expect that an eq test of even a single page ought to trigger this if all of the following holds:

  • Printing is tested, by specifying "print": true, in the manifest.
  • An empty AnnotationStorage-instance is provided, by specifying "annotationStorage": {}, in the manifest.

@timvandermeij
Copy link
Contributor

Why is that though

I thought so because of the "since they were not rendered in annotation_layer" part. If we add a reference test we have to render the page and I thought this bug would not show up then. I might be wrong here and I see that a test is now added, so we should verify if this indeed catches the bug.

@timvandermeij
Copy link
Contributor

This PR needs a rebase.

@calixteman calixteman force-pushed the checks branch 2 times, most recently from 489a57f to 589b18d Compare October 7, 2020 09:32
Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally had some time to review this; sorry for the delay. Looks good with these final comments resolved, the most important one being the reference test that doesn't seem to work.

"type": "eq",
"print": true,
"annotationStorage": {
"1605R": true
Copy link
Contributor

@timvandermeij timvandermeij Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that this patch itserlf fixes the reported issue, but I can't get this reference test working when checking out this patch and I also don't see how this is supposed to work. The prefilled file seems to only have prefilled content on page 1 and this page is always rendered, so there is an annotation layer and the content is simply in the annotation storage. Checkbox 1605R is also on the first page, so that will also work. I don't see any changes in the output before/after this patch, which confirms my suspicion that this most likely doesn't work as expected.

Did you try the suggestion from #12395 (comment)? You can run the reference tests locally before/after applying this patch to check if the test indeed works as expected.

Since I found that your steps in #12395 (comment) do work, perhaps this test can be made in the same way by providing a PDF with text prefilled on page 3 and then printing it?

const value = annotationStorage[this.data.id];
if (value === undefined) {
// No change
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined actually means "not rendered" because otherwise the value would be false/true depending on the checked state. Given that we also don't have this comment in WidgetAnnotation.save, I'd say we can just remove this line here and in _saveRadioButton below.

@timvandermeij
Copy link
Contributor

@calixteman Since form support is getting close to being enabled upstream, it would be great if we can get this PR merged. For the reference test, I recommend to run gulp makeref locally with this branch checked out, with all entries in test/test_manifest.json removed except for the one added in this patch so you can iterate quickly, and then looking at the reference image in the test/ref folder to see what I currently see and if a fix has effect.

@calixteman
Copy link
Contributor Author

@calixteman Since form support is getting close to being enabled upstream, it would be great if we can get this PR merged. For the reference test, I recommend to run gulp makeref locally with this branch checked out, with all entries in test/test_manifest.json removed except for the one added in this patch so you can iterate quickly, and then looking at the reference image in the test/ref folder to see what I currently see and if a fix has effect.

It should be ok now, sorry for the delay.
I ran the test without the patch and nothing is printed on page 2 and it's ok with it.

@timvandermeij
Copy link
Contributor

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/4c26b560f7fe076/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/4c26b560f7fe076/output.txt

Total script time: 2.40 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/4c26b560f7fe076/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor

WARNING: MD5 of file "pdfs/prefilled_f1040.pdf" does not match file. Expected "6c45b2c43e365bb7c88b9cddca0a4865" computed "2335da66fb7c2c3b84971597f27785e2"

Did the PDF file change? If so, the hash also needs to be changed in the test manifest.

@calixteman
Copy link
Contributor Author

WARNING: MD5 of file "pdfs/prefilled_f1040.pdf" does not match file. Expected "6c45b2c43e365bb7c88b9cddca0a4865" computed "2335da66fb7c2c3b84971597f27785e2"

Did the PDF file change? If so, the hash also needs to be changed in the test manifest.

My bad, I fixed it, sorry.
Anyway the CI is failing but I guess that isn't my fault, else tell me.

@timvandermeij
Copy link
Contributor

Oh, that's indeed not the fault of this PR. We'll look into that.

@timvandermeij
Copy link
Contributor

Node.js 14 became LTS today, causing the CI builds to fail because the caches still contained packages for the previous LTS version. Purging the cache and retriggering the CI build fixed the issue.

@timvandermeij
Copy link
Contributor

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/1e5bacfcc405f09/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/1e5bacfcc405f09/output.txt

Total script time: 24.93 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/1e5bacfcc405f09/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/f7a1bbf174f8bef/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/f7a1bbf174f8bef/output.txt

Total script time: 3.94 mins

Published

@timvandermeij timvandermeij merged commit ea4d88a into mozilla:master Oct 27, 2020
@timvandermeij
Copy link
Contributor

Thank you!

/botio-linux makeref

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/3d2676d61a9df20/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/3d2676d61a9df20/output.txt

Total script time: 23.98 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

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

Successfully merging this pull request may close these issues.

4 participants