Skip to content
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

Page merging broken since #1371 #1601

Closed
raphaelm opened this issue Feb 3, 2023 · 2 comments · Fixed by #1567
Closed

Page merging broken since #1371 #1601

raphaelm opened this issue Feb 3, 2023 · 2 comments · Fixed by #1567
Labels
help wanted We appreciate help everywhere - this one might be an easy start! is-bug From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF workflow-merge From a users perspective, merging is the affected feature/workflow

Comments

@raphaelm
Copy link

raphaelm commented Feb 3, 2023

We are using PyPDF to implement a "n-up" feature in our application. With the upgrade from PyPDF 2.12.x to PyPDF 3.x, this broke. We are now only getting white pages as the output.

Environment

$ python -m platform
Linux-6.0.9-arch1-1-x86_64-with-glibc2.36

$ python -c "import pypdf;print(pypdf.__version__)"
3.3.0

Code + PDF

Our actual source code is here:
https://github.com/pretix/pretix/blob/79ee89bde91293e22c314c436ac095b3c9b811c5/src/pretix/plugins/badges/exporters.py#L218-L242

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

from pypdf import PdfWriter, PdfReader

in_pdf = PdfReader('badges-38.pdf')
out_pdf = PdfWriter()

page_1 = out_pdf.add_blank_page(in_pdf.pages[0].mediabox[2], in_pdf.pages[0].mediabox[3])
page_1.merge_page(in_pdf.pages[0])

out_pdf.write('pypdf3.pdf')

from PyPDF2 import PdfWriter, PdfReader  # with PyPDF2 being version 2.12.1

in_pdf = PdfReader('badges-38.pdf')
out_pdf = PdfWriter()

page_1 = out_pdf.add_blank_page(in_pdf.pages[0].mediabox[2], in_pdf.pages[0].mediabox[3])
page_1.merge_page(in_pdf.pages[0])

out_pdf.write('pypdf2.pdf')

pypdf2.pdf will look the same as badges-38.pdf. pypdf3.pdf is completely white. The only difference is the PyPDF version.

It does not seem to be dependent on the input file, but alas, here's one I used:
badges-38.pdf

@MartinThoma MartinThoma added is-bug From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF workflow-merge From a users perspective, merging is the affected feature/workflow help wanted We appreciate help everywhere - this one might be an easy start! labels Feb 3, 2023
@pubpub-zz
Copy link
Collaborator

Thanks for the report
I've completed #1567 to fix this issue (may be linked the add_blank_page() but not sure it was this only ?

@raphaelm
Copy link
Author

raphaelm commented Feb 6, 2023

Amazing, thanks for the quick fix and release <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We appreciate help everywhere - this one might be an easy start! is-bug From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF workflow-merge From a users perspective, merging is the affected feature/workflow
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants