Can't delete PDF file written from Python

Based on the sample code at I’ve written an app to convert a file to a PDF and a XOD

I’ve got a test case down to:

pdfdoc = PDFDoc()
Convert.ToPdf(pdfdoc, “src.docx”)
pdfdoc.Save(“dst.pdf”, SDFDoc.e_remove_unused)

On Windows (Python 2.7, 64 bit) I get an error from the unlink call:

WindowsError: [Error 32] The process cannot access the file because it is being used by another process: c:\folder\dst.pdf

What can I do to work around this issue?

Hi, the pdfdoc object is still holding onto this resource, “dst.pdf”, so you need to call


then you can delete the file. This applies to all the memory managed languages (Java, C#. etc).