Search code examples
c#.netpdfaxacropdf

How to know whether AxAcroPdf.printWithDialog() resulted in a print or not?


I'm using the method printWithDialog() from the AxAcroPdf control in C# which seems to return void.

When a document is printed I want to store a record of it, but I can't work out how to find out whether the user pressed Cancel or OK on the print dialog, so documents are being recorded even if the user changes their mind about printing (before the user pressed any button in fact).

Is it possible to find out whether the document was actually printed or not?

If not, can I set the printer for the AxAcroPdf control first, then just call the printAll() method to get around this issue?


Solution

  • It seems like there is no way to tell whether the document was printed, without watching the print queue (which I didn't want to do because it would cause a delay).

    My workaround was to use a PrintDialog to choose a printer, then set that printer to be the default printer using p/invoke as here: https://stackoverflow.com/a/971634/1341694 , then print using PrintAll(), setting the default printer back as it was afterwards if it was changed.