Skip to content

fix(document): account for page padding in rotation layer sizing#747

Merged
kduncanhsu merged 2 commits into
box:masterfrom
kduncanhsu:fix/rotation-annotation-offset
May 8, 2026
Merged

fix(document): account for page padding in rotation layer sizing#747
kduncanhsu merged 2 commits into
box:masterfrom
kduncanhsu:fix/rotation-annotation-offset

Conversation

@kduncanhsu
Copy link
Copy Markdown
Contributor

@kduncanhsu kduncanhsu commented May 7, 2026

Summary

  • Fixes bug where annotations on PDF's appear in slightly different positions when PDF is rotated
  • Solution: subtract the 30px vertical page padding (15px top + 15px bottom from Preview SDK) when computing annotation layer dimensions
  • pageEl.clientHeight was being used directly, but it includes padding that isn't part of the annotation content area — causing the layer to be oversized and percentage-based annotation coordinates to resolve to slightly wrong pixel positions

Test plan

  • Draw and save annotations on a PDF at 0° rotation
  • Rotate the PDF 90°, 180°, and 270° — verify annotations remain precisely positioned
  • Verify annotations near page edges (where offset was most visible) are no longer shifted

The annotation layer dimensions were computed using pageEl.clientHeight
which includes 30px of vertical padding (15px top + 15px bottom) from
the Preview SDK. When swapping dimensions for orthogonal rotations, this
padding was incorrectly included, causing the layer to be oversized and
annotations to appear offset by a few pixels after rotation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kduncanhsu kduncanhsu requested a review from a team as a code owner May 7, 2026 23:36
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 7, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ kduncanhsu
❌ Duncan Hsu


Duncan Hsu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@kduncanhsu kduncanhsu merged commit 66cad72 into box:master May 8, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants