-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFis-regressionRegression introduced as a side-effect of another changeRegression introduced as a side-effect of another change
Description
The file scaling example from the docs does not work. The content is scaled correctly, but the resulting page size is unexpected, as if the scaling got applied twice. See the reproduction example.
Environment
Which environment were you using when you encountered the problem?
$ python -m platform
Linux-6.14.0-32-generic-x86_64-with-glibc2.41
$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==6.1.1, crypt_provider=('cryptography', '45.0.7'), PIL=none
Code + PDF
This is a minimal, complete example that shows the issue:
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "pypdf",
# ]
# ///
from pypdf import PdfReader, PdfWriter
reader = PdfReader("input.pdf") # A4 document
writer = PdfWriter()
for page in reader.pages:
page.scale_by(0.5) # Expected A6
writer.add_page(page)
# The output contains A8 pages instead,
# with the content scaled by the factor 0.5
writer.write("output.pdf")
The input PDF, A4:
input.pdf

The output contains A8 pages, not A6 as expected. The content is scaled correctly by the factor 0.5
:
Metadata
Metadata
Assignees
Labels
is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFis-regressionRegression introduced as a side-effect of another changeRegression introduced as a side-effect of another change