Repository navigation
Conversation
Normalize raw annotation points relative to the original MediaBox before rotation, then restore the existing root-page coordinate offsets. Keep the unrotated path and global page bbox convention unchanged. Expand the synthetic crop regressions to 77 cases, including nonzero and fractional origins, endpoint ordering, nested/relative/partial crops and actual PDFium rendering. Previous PR head: 45 failures / 32 passes; this commit: 77 passes. Full suite: 250 passes. make lint passes. Validated with repository-pinned pdfminer.six==20260107 on Python 3.12.14. Independent native-renderer/API review passes 12 pages x 16 checks; Poppler independently corroborates all 12 synthetic page geometries. Only annotation handling changes; the global inversion work in jsvine#1381 remains separate. AI-assisted and independently reviewed. Synthetic logical crop/link extraction only, not exported-PDF or production proof.
This was referenced Nov 1, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix lost or displaced annotations/hyperlinks after cropping a rotated page. Annotation
/Rectcoordinates are defined in the original page's coordinate system, so rotation must useroot_page.width/root_page.height, rather than the cropped page dimensions.A synthetic 300×400 page with a URI link at
[50,100,150,130]illustrates the problem:page.crop(page.hyperlinks[0]'s bbox).hyperlinksis empty at 90°, 180°, and 270°. The uncropped hyperlink coordinates are correct. This also reproduces in PyPI 0.11.10.Changes
Validation
Against develop
2fcbe6a6264201e9ae3e661c01c39b4111eb9af0, Python 3.12:make lint: flake8, strict mypy (20 source files), Black and isort all passed with the repository's pinned tooling/type stubs.All fixtures are synthetic and contain no external/customer data. Uncropped pages retain existing behavior because
root_pageis the page itself. Remote CI has not yet run. This contribution was prepared with AI assistance and independently reviewed and tested.