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:
output.pdf

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?
Code + PDF
This is a minimal, complete example that shows the issue:
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:output.pdf
