Skip to content

Make Popup annotations always have noRotate flag set as true #20043

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 1 commit into from
Jul 3, 2025

Conversation

yyliu12
Copy link
Contributor

@yyliu12 yyliu12 commented Jun 27, 2025

In PDF, pages can be rotated using their Rotate property (7.7.3.3). An annotation on a PDF can have a NoRotate flag set, in which case the annotation will not rotate (12.5.3). The PDF specification also requires that some annotations will always have the NoRotate flag set, including the Text annotation (12.5.6.4).

The NoRotate flag was implemented in PDF.js in pull request #16110. However, the implementation only works if a PDF editor creates both a Popup annotation and a Text annotation. Adobe Acrobat does this. However, some PDF editors only create a Text annotation. Even if the Text annotation has the NoRotate flag set, the popup created by PDF.js will not have the NoRotate flag. This is because the annotation layer does not pass the NoRotate flag to the Popup object when creating it. This pull request fixes that.

I have created a test PDF with a single page that has the Rotate property set. The left comment was created using Adobe Acrobat while the right comment was created using a PDF editor that does not create the Popup annotation.

Here's how the right comment renders in Acrobat:

image

Here's how it displays in the version of pdf.js available at mozilla.github.io:

image

And here's how it displays in pdf.js after applying the code attached to this pull request:

image

Test PDF: Testing file.pdf

@calixteman
Copy link
Contributor

@yyliu12 would you mind to update your patch in order to take into account: #20043 (comment) ?
Thank you.

@timvandermeij
Copy link
Contributor

timvandermeij commented Jun 30, 2025

In addition to the above, please also add a reference test for this behavior to avoid regressions. You can add the file you already created to test/pdfs as pr20043.pdf (and update .gitignore) and then use the add_test.mjs tool (here: https://github.com/mozilla/pdf.js/blob/master/test/add_test.mjs) to update the manifest file.

This will look something like the one added in c5449a9#diff-bbeef90df04bff7617f7ef59e3f37cac92192c5169bc500d857bd6fb107fcabd and should consist of the PDF file itself, the .gitignore entry and the test_manifest.json entry.

Finally, make sure to add "annotations": true to the manifest entry so that the actual annotation is covered; see for example https://github.com/mozilla/pdf.js/pull/20041/files#diff-9bc50ce4ba8a4ba8d322114a3cc05fa62005a40b52223059200ca07087dd5a61R12150.

@yyliu12 yyliu12 force-pushed the popup-rotation-fix branch 2 times, most recently from 8e4347c to c4685a1 Compare July 2, 2025 09:12
@yyliu12
Copy link
Contributor Author

yyliu12 commented Jul 2, 2025

All done. Please let me know if anything is not to snuff.

@calixteman
Copy link
Contributor

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @calixteman received. Current queue size: 1

Live output at: http://54.241.84.105:8877/5238ed11ea98021/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/5238ed11ea98021/output.txt

Total script time: 30.40 mins

  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: Passed

@timvandermeij timvandermeij changed the title Make Popup annotations take NoRotate flag of their parent Make Popup annotations always have noRotate flag set as true Jul 2, 2025
@timvandermeij
Copy link
Contributor

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/b7126efa1f7f4d5/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/b7126efa1f7f4d5/output.txt

Total script time: 0.98 mins

Published

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.

The change looks good to me now, but before we merge this please put the nice context from the PR description (in a summarized way) in the commit message itself so it's also visible using e.g. git log for future reference.

Thank you for your contribution!

Necessary because when there is no Popup annotation created along
with a Text annotation, the Popup annotation created by pdf.js
does not receive the noRotate flag
@yyliu12 yyliu12 force-pushed the popup-rotation-fix branch from c4685a1 to d8ecfad Compare July 2, 2025 20:57
@calixteman calixteman merged commit 2d0ba7d into mozilla:master Jul 3, 2025
9 checks passed
@calixteman
Copy link
Contributor

/botio makeref

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/93b39418842916c/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/4653081775128fd/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/93b39418842916c/output.txt

Total script time: 15.99 mins

  • Make references: Passed
  • Check references: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/4653081775128fd/output.txt

Total script time: 23.97 mins

  • 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