-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Stream has ended unexpectedly #454
Comments
I experience the same error for some of my PDF files
|
MartinThoma
added
is-bug
From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF
Has MCVE
A minimal, complete and verifiable example helps a lot to debug / understand feature requests
labels
Apr 7, 2022
I can confirm for
|
Simplifying it a bit: from PyPDF2 import PdfReader, PdfWriter
def prepare_stream():
from io import BytesIO
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
packet = BytesIO()
can = canvas.Canvas(packet, pagesize=A4)
can.drawString(10, 10, "ADDED INFO")
can.save()
packet.seek(0)
return packet
reader = PdfReader("out.pdf", strict=False)
writer = PdfWriter()
page = reader.pages[0]
stream = prepare_stream()
added_info = PdfReader(stream)
to_merge = added_info.pages[0]
page.merge_page(to_merge)
writer.add_page(page)
writer.write("pypdf.pdf") |
I guess the issue is that PyPDF2 tries to read the stream twice - once for |
I can confirm it for
|
pubpub-zz
added a commit
to pubpub-zz/pypdf
that referenced
this issue
Aug 11, 2022
fixes py-pdf#454 observed in case of \0 - \9 in streams
MartinThoma
pushed a commit
that referenced
this issue
Aug 11, 2022
Observed in case of \0 - \9 in streams Closes #454
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
out.pdf
with this code:
The text was updated successfully, but these errors were encountered: