GemBox.Pdf.Examples icon indicating copy to clipboard operation
GemBox.Pdf.Examples copied to clipboard

Printing is not working

Open MistressPlague opened this issue 1 year ago • 2 comments

Even when using the print.pdf console example, printing does not work. It is a exception of file is in use by a process.

This is even when using the 'using' keyword for automatic disposing of the loaded pdf document.

MistressPlague avatar Nov 02 '24 22:11 MistressPlague

For clarity, nothing is using the file. I have confirmed such with both IOBit Unlocker and file locksmith. The issue could only be your code trying to open two streams on the same file at once (PdfDocument.Load opens a stream, for example)

MistressPlague avatar Nov 02 '24 22:11 MistressPlague

Hi,

I was unable to reproduce this issue. Can you try using this:

var bytes = File.ReadAllBytes("input.pdf");
var stream = new MemoryStream(bytes);

using (var document = PdfDocument.Load(stream))
    document.Print("printer name");

Does this work for you?

Regards, Mario

mario-gembox avatar Nov 04 '24 04:11 mario-gembox