Skip to content

Generated PDF is corrupted when using Python 3.13.7 but not with 3.12.10 #3450

@TheGiolly

Description

@TheGiolly

I have a script that does the following:

  1. Reads an input.pdf file that contains a 4x10 grid of labels.
  2. Extracts the texts that are present under every bercode.
    Each extracted text matches the name of a pdf file that is contained in the labels folder.
  3. A new pdf is generated by arranging the contents of the pdf files contained in the labels folder in a 3x5 grid.

Example:
The input.pdf file contains 25 barcodes/texts of which 10 are ABCD and 15 are EFGH.
The output.pdf file will have 2 pages in which the will be 10 contents of labels/ABCD.pdf and 15 contents of labels/EFGH.pdf.

When using Python 3.13.7, the output.pdf file is corrupted.
When using Python 3.12.10, the output.pdf file is correct.

Environment

fpdf2 version is 2.8.4

Which environment were you using when you encountered the problem?

$ python --version 
Python 3.13.7

$ python -m platform
Windows-11-10.0.26100-SP0

$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==6.0.0, crypt_provider=('local_crypt_fallback', '0.0.0'), PIL=11.3.0

The following environment doesn't generate the problem

$ python --version 
Python 3.12.10

$ python -m platform
Windows-11-10.0.26100-SP0

$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==6.0.0, crypt_provider=('local_crypt_fallback', '0.0.0'), PIL=11.3.0

Code + PDF

This is a minimal, complete example that shows the issue:
main.zip

These are the output files, generated with Python 3.13.7 and 3.12.10.
Look for example from page 38 onwards.
output_3-12-10.pdf
output_3-13-7.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions