Skip to content

[api-minor] Introduce a new annotationMode-option, in PDFPageProxy.{render, getOperatorList} #13923

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

Merged
merged 2 commits into from
Aug 25, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

This is a follow-up to PRs #13867 and #13899.

This patch is tagged api-minor for the following reasons:

  • It replaces the renderInteractiveForms/includeAnnotationStorage-options, in the PDFPageProxy.render-method, with the single annotationMode-option that controls which annotations are being rendered and how. Note that the old options were mutually exclusive, and setting both to true would result in undefined behaviour.

  • For improved consistency in the API, the annotationMode-option will also work together with the PDFPageProxy.getOperatorList-method.

  • It's now also possible to disable all annotation rendering in both the API and the Viewer, since the other changes meant that this could now be supported with a single added line on the worker-thread[1]; fixes Option to disable showing of PDF annotations #7282.


[1] Please note that in order to simplify the overall implementation, we'll purposely only support disabling of all annotations and that the option is being shared between the API and the Viewer. For any more "specialized" use-cases, where e.g. only some annotation-types are being rendered and/or the API and Viewer render different sets of annotations, that'll have to be handled in third-party implementations/forks of the PDF.js code-base.

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@mozilla mozilla deleted a comment from pdfjsbot Aug 22, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 22, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 22, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 22, 2021
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/0e98c35cec25aac/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/7455ea80382b00d/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/0e98c35cec25aac/output.txt

Total script time: 33.48 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 6
  different first/second rendering: 3

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/7455ea80382b00d/output.txt

Total script time: 39.54 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 9

Image differences available at: http://3.101.106.178:8877/7455ea80382b00d/reftest-analyzer.html#web=eq.log

@Snuffleupagus Snuffleupagus marked this pull request as ready for review August 22, 2021 18:40
@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

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

Total script time: 5.37 mins

Published

@mozilla mozilla deleted a comment from lgtm-com bot Aug 23, 2021
@brendandahl
Copy link
Contributor

I think this is still considered a major version change since it removes/changes arguments to the API. A user could not take this version if they had used some different values and seamlessly upgrade. We'll need to either 1) do a major release or 2) convert this to a minor release and leave the old options and mark them as deprecated and have them populate the new arguments.

@Snuffleupagus
Copy link
Collaborator Author

Snuffleupagus commented Aug 23, 2021

I think this is still considered a major version change since it removes/changes arguments to the API.

Well, this wouldn't exactly be the first time that we've made strictly speaking backwards incompatible changes in api-minor patches :-)

convert this to a minor release and leave the old options and mark them as deprecated and have them populate the new arguments.

The issue is then exactly how to do that conversion consistently and correctly, since a pretty big issue in the current implementation is that as mentioned above the two old options are unfortunately mutually exclusive!?

Edit: I've now tried to add fallback values for the old options, which should hopefully cover most use-cases. In particular the renderInteractiveForms-option will take precedence over the includeAnnotationStorage-option, which overall probably makes the most sense since if the form elements aren't in the operatorList there's nothing to insert AnnotationStorage-data into.

….{render, getOperatorList}`

*This is a follow-up to PRs 13867 and 13899.*

This patch is tagged `api-minor` for the following reasons:
 - It replaces the `renderInteractiveForms`/`includeAnnotationStorage`-options, in the `PDFPageProxy.render`-method, with the single `annotationMode`-option that controls which annotations are being rendered and how. Note that the old options were mutually exclusive, and setting both to `true` would result in undefined behaviour.

 - For improved consistency in the API, the `annotationMode`-option will also work together with the `PDFPageProxy.getOperatorList`-method.

 - It's now also possible to disable *all* annotation rendering in both the API and the Viewer, since the other changes meant that this could now be supported with a single added line on the worker-thread[1]; fixes 7282.

---
[1] Please note that in order to simplify the overall implementation, we'll purposely only support disabling of *all* annotations and that the option is being shared between the API and the Viewer. For any more "specialized" use-cases, where e.g. only some annotation-types are being rendered and/or the API and Viewer render different sets of annotations, that'll have to be handled in third-party implementations/forks of the PDF.js code-base.
@Snuffleupagus Snuffleupagus force-pushed the AnnotationMode branch 2 times, most recently from 2365431 to 23b47d3 Compare August 23, 2021 23:18
…eAnnotationStorage` options, in `PDFPageProxy.render`

*This is done separately from the previous patch, to make it easier to revert these changes once they've been included in a couple of releases.*

Please note that because these two options are mutually exclusive, which is a large part of the reason for the previous patch, it's not guaranteed that the fallback-values will always be correct in every situation (but it's the best that we can do).
@brendandahl
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/c7b4675ade3eea5/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

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

Total script time: 27.89 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  errors: 608
  different ref/snapshot: 8
  different first/second rendering: 1

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/c7b4675ade3eea5/output.txt

Total script time: 40.10 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 8
  different first/second rendering: 2

Image differences available at: http://3.101.106.178:8877/c7b4675ade3eea5/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator Author

/botio browsertest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @Snuffleupagus received. Current queue size: 0

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_browsertest from @Snuffleupagus received. Current queue size: 0

Live output at: http://3.101.106.178:8877/7e5a1cdc10e9ff4/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

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

Total script time: 24.24 mins

  • Regression tests: FAILED
  errors: 586
  different ref/snapshot: 4
  different first/second rendering: 1

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

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux browsertest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @Snuffleupagus received. Current queue size: 0

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/7e5a1cdc10e9ff4/output.txt

Total script time: 35.58 mins

  • Regression tests: FAILED
  different ref/snapshot: 9
  different first/second rendering: 1

Image differences available at: http://3.101.106.178:8877/7e5a1cdc10e9ff4/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

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

Total script time: 24.20 mins

  • Regression tests: FAILED
  errors: 586
  different ref/snapshot: 6
  different first/second rendering: 1

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

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux browsertest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/223e38131381a6e/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/223e38131381a6e/output.txt

Total script time: 23.72 mins

  • Regression tests: FAILED
  errors: 605
  different ref/snapshot: 6
  different first/second rendering: 1

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

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux browsertest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @Snuffleupagus received. Current queue size: 0

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

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

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

Total script time: 23.87 mins

  • Regression tests: FAILED
  errors: 603
  different ref/snapshot: 6
  different first/second rendering: 2

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

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux browsertest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/35ac4a66ec9c8ba/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/35ac4a66ec9c8ba/output.txt

Total script time: 29.69 mins

  • Regression tests: FAILED
  different ref/snapshot: 4
  different first/second rendering: 1

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

@Snuffleupagus Snuffleupagus merged commit bb81f40 into mozilla:master Aug 25, 2021
@Snuffleupagus Snuffleupagus deleted the AnnotationMode branch August 25, 2021 09:55
@timvandermeij
Copy link
Contributor

Really nice work! The previous options indeed grew over time with all the forms and storage work, so it's good to re-evaluate that and introduce a single option that captures all variants.

@CetinSert
Copy link
Contributor

Hi!

When will the new annotationMode option make it to a stable or beta release?

I would like to update my usage of the library to this.

@timvandermeij
Copy link
Contributor

This patch will be part of the upcoming pre-release (beta) version, but we don't have a release date yet.

@pardoman
Copy link

These changes look promising!

Question: How could I use the library to render only the annotations layer?

Thanks

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.

Option to disable showing of PDF annotations
6 participants