Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Sep 16, 2016 1:55 pm

When I try to print my PDF file from the webserver using Spire.Pdf PdfDocument I get the following error message:

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.

How can I print a PDF file using Spire.Pdf PdfDocument without it attempting to display a message box from the webserver?

Here is my code:

PdfDocument pdfdocument = new PdfDocument();
pdfdocument.LoadFromFile(strFilePath);
pdfdocument.PrinterName = printerName;
pdfdocument.PageScaling = PdfPrintPageScaling.FitSize;
pdfdocument.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Left = 25;
pdfdocument.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Right = 25;
pdfdocument.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Bottom = 25;
pdfdocument.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Top = 25;
pdfdocument.PrintDocument.PrinterSettings.Copies = 1;
pdfdocument.PrintDocument.
pdfdocument.PrintDocument.Print();
pdfdocument.Dispose();

Thanks!

JT8101962
 
Posts: 4
Joined: Thu Sep 15, 2016 11:13 pm

Mon Sep 19, 2016 9:25 am

Hi,

Thanks for your inquiry. Please add the following line code.
Code: Select all
pdfdocument.PrintDocument.PrintController = new StandardPrintController();


Sincerely,
Alan
E-iceblue support team
User avatar

Alan.Li
 
Posts: 35
Joined: Mon Sep 05, 2016 2:51 am

Return to Spire.PDF