-
Notifications
You must be signed in to change notification settings - Fork 685
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.to_image() causes error "PermissionError: [WinError 32] The process cannot access the file because it is being used by another process " #1072
Comments
Hi @domdrag, and glad to hear that the library has been useful. I've tried running your code on my computer, but cannot replicate the error. (Everything runs as expected.) I'm using a Mac, though. To the Windows users in the |
Confirmed this problem on Windows (Python 3.12 on Windows 10). This is probably fixed by #1090 since the problem there is precisely that we aren't explicitly closing the |
Confirmed fixed by #1090 |
See #1089 (comment) for an explanation. If the file handle was opened within pypdfium2/pdfium, it will also close it, but then it still falls to the caller to close the pypdfium2 object that holds the file handle, because otherwise we'll have to wait for the garbage collector, which is unpredictable. This is neither pypdfium2 decision nor bug, but rather file handle and object hierarchy logic.
pypdfium2 does install a finalizer that will close the FD, if the input is a file path, or a file handle and |
Hi,
amazing work with the library, it has been super useful. Not sure if this is a bug or if I'm doing something wrong.
Describe the bug
Page.to_image()
method causes the PDF file stuck in another process. Trying to e.g.os.remove
the PDF file afterward causesthe PermissionError.
Have you tried repairing the PDF?
I've tried this and stumbled upon the same issue mentioned here.
However, this issue shouldn't be due to the PDF file itself.
Code to reproduce the problem
PDF file
sample.pdf
Expected behavior
Expected behavior was to successfully remove the PDF file.
The code works if we comment the
image = page.to_image()
line.Actual behavior
PermissionError exception is raised.
Screenshots
Environment
Additional context
NA
The text was updated successfully, but these errors were encountered: