-
Notifications
You must be signed in to change notification settings - Fork 1.5k
BUG: PageObject.scale() scales media box incorrectly (#3487) #3489
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
base: main
Are you sure you want to change the base?
Conversation
I'm not sure if I'm required to create a test for this fix. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3489 +/- ##
=======================================
Coverage 97.09% 97.09%
=======================================
Files 56 56
Lines 9658 9658
Branches 1748 1748
=======================================
Hits 9377 9377
Misses 168 168
Partials 113 113 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I have not been aware that the faulty commit would not have proper tests, thus I did not require a new one. With the current regression, we should add one to ensure this does not break again.
This is a very strange side effect, as the boxes all look correct: @pytest.mark.enable_socket
def test_scale_by():
"""Tests for #3487"""
url = "https://github.com/user-attachments/files/22685841/input.pdf"
name = "issue3487.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
original_box = RectangleObject((0, 0, 595.275604, 841.88974))
expected_box = RectangleObject((0.0, 0.0, 297.637802, 420.94487))
for page in reader.pages:
assert page.artbox == original_box
assert page.bleedbox == original_box
assert page.cropbox == original_box
assert page.mediabox == original_box
assert page.trimbox == original_box
page.scale_by(0.5)
assert page.artbox == expected_box
assert page.bleedbox == expected_box
assert page.cropbox == expected_box
assert page.mediabox == expected_box
assert page.trimbox == expected_box Thus, we need a rendering test with Ghostscript here to actually detect this bug (which has already been fixed in the past in #1314 - without adding a test). |
If I am not mistaken, the added test is not sufficient, as running it against main is successful as well, not providing any benefits (as outlined in my comment as well). We have to add a test similar to the discussions in the issue by comparing the rendering results with Ghostscript, as mentioned in my comment as well (examples are already available for watermarking for example). |
Partly undo d89fb78#diff-153e5cee71ddf471246ff5c0e198345f005942a540a8f39297736f0b620d631dR1587-R1592 since the changed order of updates to the page boundaries results in wrongly scaled pdfs.