Repository navigation
Conversation
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.
Page.to_image(force_mediabox=True)currently renders only the CropBox, then pads the image to the MediaBox with black pixels. Actual PDF content outside the CropBox is lost. In the new synthetic fixture, a red rectangle outside the CropBox disappears while a blue rectangle inside remains visible.Pass pdfminer's unrotated, inherited MediaBox to PDFium before rendering, then compute the image scale and any derived-page crop from the box actually rendered. Using the parsed box also avoids relying on PDFium box getters that do not inherit page-tree boxes.
The new 812-byte PDF has four page rotations, with both boxes inherited from their parent. Twenty cases check actual content pixels, default/resolution/width/height sizing, derived-page cropping, and the default CropBox rendering. Eighteen of the twenty cases fail on unchanged develop; the two default-rendering controls already pass. A binary comment prevents Git's automatic newline conversion from invalidating PDF byte offsets on Windows.
The existing fractional-box fixture now renders at 2226 x 2920 pixels at 72 DPI, matching its rotated 2225.2 x 2919.69 point MediaBox and an independent Poppler render. Its old 2227 x 2923 expectation came from scaling the cropped bitmap. The corrected assertion also fails when run with the original display.py.
Validation on Windows, CPython 3.12.10:
Changelog and contributor credit are included. No new dependencies are required. Linux and other Python versions have not been verified locally.
AI assistance was used to prepare this change and its regression tests.