-
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
Problem with closing PDF file saved by PyPDF2 #963
Comments
I checked which version work properly and that is: |
Thank you for reporting the issue 🙏 I don't quite understand: Which versions work and which are broken? |
Please note that with open(path, "wb") as fh:
pdf.write(fh) After the with-block, the file handle |
I know use with style is more pythonic but using "with" it didn't work too. The versions which work is Code# from PyPDF2 import PdfFileWriter
import os
c_dir = os.getcwd()
path = os.path.join(c_dir, 'test_10.pdf')
pdf = PdfFileWriter()
pdf.addBlankPage(100, 100)
file = open(path, 'wb')
pdf.write(file)
file.close()
pdf2 = PdfFileWriter()
path2 = os.path.join(c_dir, 'test_11.pdf')
with open(path2, "wb") as fh:
pdf2.addBlankPage(100, 100)
pdf2.write(fh) Both work wrong on version >= 1.27.6 |
@Kaemer1645 , |
@Kaemer1645, |
@MartinThoma , |
@pubpub-zz of course I can |
@pubpub-zz I didn't have the time to look into that since yesterday, but what popped into my mind is #414 (introduced in 1.27.6) |
Hi there,
If this could help, when I try to merge the problematic files, it return this messages at some point : |
The issue comes from #412 (refer to discussion #355) when My current proposal would be to remove call to @MartinThoma , @MasterOdin your opinion ? |
@Kaemer1645, if you want for the moment, you may add
before calling |
@mawr-san / @Kaemer1645 Would you please check if the following PDF also has the mentioned issue: If the bug doesn't appear with that PDF, we can merge #970 (going with the fix proposed by @pubpub-zz ) |
@MartinThoma everything works fine! |
Issue: When creating files with the current PpdfWriter, Adobe Acrobat asks 'would you like to save this file' when attempting to close it - although no changes were made. Fix: Remove 'self.set_need_appearances_writer()' from writers __init__ function Caused-by: #412 (see #355) Closes #963 Co-authored-by: pubpub-zz <4083478+pubpub-zz@users.noreply.github.com>
Nice! Thanks for confirming! The fix is now in the |
I'm create PDF file using PyPDF2. After that when I'm oppening this file with Adobe Acrobat and I would like to close it. The window appears with messege like "Would you like to save this file?"
I haven't got this problem with previous versions of PyPDF2.
Environment
$ python -m platform Windows-10-10.0.19044-SP0 $ python -c "import PyPDF2;print(PyPDF2.__version__)" 2.1.0
Code
This is a minimal, complete example that shows the issue:
PDF
test_2.pdf
The text was updated successfully, but these errors were encountered: