pvginkel / PdfiumViewer

PDF viewer based on Google's PDFium.
Apache License 2.0
972 stars 418 forks source link

How to close the opened file #127

Closed Shenyz163 closed 7 years ago

Shenyz163 commented 7 years ago

I can`t delete the pdf file after load in the pdfviewer. (this file is being used by another process).

pvginkel commented 7 years ago

The reason for this is that the PDF file is still in use. PdfiumViewer by default does not load the whole PDF file into memory to keep memory usage as low as possible. Instead, data is streamed into the control as necessary.

There are a few solutions to this I can think of:

pdfViewer1.Document = PdfDocument.Load(new MemoryStream(File.ReadAllBytes(form.FileName)));