-
Notifications
You must be signed in to change notification settings - Fork 16
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
PDF file is not closed correctly #15
Comments
Can you specify the steps to reproduce the issue in detail, I was not able to reproduce it. |
Yes, since yesterday.
Windows 10 Pro 10.0.18362 Build 18362 You can use the example from the tutorial: The following example throws a PermissionError [WinError 32] when deleting a file.
When opened with "with", the file is properly deleted without errors.
I didn't find in the documentation a way to close the file when it is opened with |
Thanks for reporting, its a windows specific issue. As you have find, for now if you need to do additional operations on pdf file, create
A del pdfimages_out
del doc |
That was also my consideration. I have also tried it as follows. Unfortunately the same exception is thrown. import os
from pyxpdf import Document
from pyxpdf.xpdf import PDFImageOutput, page_iterator
filename="test.pdf"
doc = Document(filename)
pdfimages_out = PDFImageOutput(doc)
for images in page_iterator(pdfimages_out):
print(images)
del pdfimages_out
del doc
os.remove(filename) |
Try this, import os
from pyxpdf import Document
from pyxpdf.xpdf import PDFImageOutput, page_iterator
filename="test.pdf"
doc = Document(filename)
pdfimages_out = PDFImageOutput(doc)
for images in page_iterator(pdfimages_out):
print(images)
del pdfimages_out
del doc
import gc
gc.collect()
os.remove(filename) My bad, actually, I think we should |
Yeah, you're right. This works. |
When I use the following command, the file is not closed correctly. For example, I cannot delete the file afterwards because the PDF file is still being used by a process.
If I write the code as follows instead, the PDF file will be closed correctly.
The text was updated successfully, but these errors were encountered: