mgaffigan / Rmg.PdfPrinting

API which uses Windows.Data.Pdf from C# to print a PDF file.
MIT License
2 stars 0 forks source link

File Handle Sometimes Remains Open #1

Closed SHADOW202021 closed 5 months ago

SHADOW202021 commented 6 months ago

Hi. You may want to use the LoadFromStreamAsync method of Windows.Data.Pdf.PdfDocument, as it seems to have an issue where it doesn't always immediately release the file resource once it is done.

mgaffigan commented 5 months ago

Hi @SHADOW202021,

I agree that the PDF renderer does keep a handle around for a bit. It also keeps a number of D2D resources. I think it does this to speed multi-page renders (think of the standard use in a PDF viewer). After some unspecified delay, the renderer does clean these up. I don't notice any leaks when looping through thousands of files.

I've not noticed any ill effect from the handle staying open for a bit. The file handle is opened as FILE_SHARE_DELETE | FILE_SHARE_READ, so unless you are opening the file for subsequent writes it should not cause a problem.

Can you clarify what issue you are running into?

mgaffigan commented 5 months ago

Closing for now. Feel free to reopen.