-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
AttributeError: 'PdfFileWriter' object has no attribute 'stream' #670
Comments
Damn. Do you have a pdf + code to share that shows this issue? |
This issue is also discussed here: https://stackoverflow.com/questions/40168027/pypdf2-pdffilewriter-has-no-attribute-stream |
|
This is a simplified version: #!/usr/bin/env python3
from PyPDF2 import PdfFileReader, PdfFileWriter, __version__ as pypdf_version
print(pypdf_version)
reader = PdfFileReader("crazyones.pdf", strict=False, overwriteWarnings=False)
for _ in range(2):
pdf_writer = PdfFileWriter()
page = reader.getPage(0)
print(page)
pdf_writer.addPage(page)
with open("foo.pdf", "wb") as f_pdf:
pdf_writer.write(f_pdf) The example works with the
It's interesting that reading the same page twice gives different results |
ce5f7ec - mixed tabs / spaces |
b030b7f - worked |
Here is what broke it: b030b7f...26e5077 |
Removing this from if data.pdf.stream.closed:
raise ValueError("I/O operation on closed file: {}".format(data.pdf.stream.name)) |
Apologies for not seeing any of the follow up here - very glad to hear that this is fixed! |
I am very happy to see that PyPDF2 is being maintained and released again - however, it seems that the latest release appears to contain a regression. We had an unpinned dependency on PyPDF2 in our library, and when 1.27.0 was released, we started seeing this error:
It seems to be entirely internal to PyPDF2, so might be causing some issues for others as well.
The text was updated successfully, but these errors were encountered: