Send PDF to Printer on Client side

I've search through the forum and found a few articles that talk about printing to PDF, but there were pretty old. I have the following code, but it doesn't work.

PdfViewer viewer = new PdfViewer();
viewer.BindPdf(pdfDoc);
viewer.PrintPageDialog = false;
viewer.AutoResize = true;
viewer.AutoRotate = true;

PrinterSettings ps = new PrinterSettings();
PageSettings pgs = new PageSettings();
PrintDocument prtdoc = new PrintDocument();

ps.PrinterName = prtdoc.PrinterSettings.PrinterName;
viewer.PrintDocumentWithSettings(pgs, ps);
//viewer.PrintDocumentWithSetup();

viewer.Close();

I got the following error:

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

Hi there


Thanks for your inquiry. It seems you are trying to use PdfViewer for client printer. I’m afraid Aspose.Pdf for .NET only supports printing on the server printer using PdfViewer, this is not a limitation of Aspose.Pdf for .NET, it is kind of a security restriction for all the web applications due to security reason.


However here is a workaround for the requirements. Please note printers are usually installed on user’s profile (especially if it’s a network printer, not a physically connected one such as on USB or parallel cable). When Administrator sees a printer it doesn’t necessarily mean they’ll be available when other user is logging on the same machine. ASP.NET applications runs as ApplicationPoolIdentity or NerworkService credential by default so the web application is unlikely to see the printers there.


There are two solutions:

1) Create an account for .NET application pool to run on, and then login as that user on the server and add the printers there

2) Run on web site under Custom account (Identity property in site’s pereferences) that is already able to work with printers.


More information about application pool usage - http://www.iis.net/learn/manage/configuring-security/application-pool-identities

Best Regards