PrintDocumentWithSettings takes a long time to print a PDF inside of a windows service

Hello Aspose - Team,



We have some issue, that the PrintDocumentWithSettings methods takes about 2 minutes to finish when it is called inside from a windows service.



The same code works fine if it is called from a Windows application.



We have Version 8.5.0.0 but we also have tried it with 10.3.0.0, the same issue.



We have attached the document to print also.



The source code:



var printerSettings = new PrinterSettings { PrinterName = “Kyocera FS-C2026MFP+ KX”, Copies = 1 };



using (var viewer = new PdfViewer { PrintPageDialog = false, AutoRotate = true })

{

foreach (var documentString in data)

{

using (var ms = new MemoryStream(Convert.FromBase64String(documentString)))

{

ms.Position = 0;





viewer.BindPdf(ms);



viewer.PrintDocumentWithSettings(printerSettings);

viewer.Close();

}

}

}





Is there any option we can try?

Any proposals?



kr,

Patrick Schmoll

Hi Patrick,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 10.3.0 in Windows application and I have also observed that PDF file is being printed in few seconds. However concerning to the issue while printing file with Windows Service, I think its something related to how your service is implemented or some scanning or filtering is being performed upon your service.

Can you please share some details/sample project which can help us in replicating the issue in our environment. We are sorry for your inconvenience.

Hello!


Just to be clear, we have logged the lines of code to get the time they needed to finish. We also thought there was something wrong in our web service first. But after we logged the executing times we saw that almost the whole executiontime is used by the PrintDocumentWithSettings - method.


However, we identified that the user account has something to do with it. The windows service is running under another account and in this account the printing takes the long time.

If we can be sure what settings help for this issue we will post it here.



kr,

Patrick Schmoll

Hi Patrick,


Thanks for sharing the details.

We will be waiting for further information from your side so that we can try replicating the issue in our environment. In case you need any related assistance, please do let us know.

Patrick,


How did you determine that the account had something to do with it? I am also running into this issue. I’ve tried changing the service to run under different accounts and it is still slow to print.

I think I found out our issue but I need to do more testing.


I logged into the server that the service is hosted on, using the credentials the service is running under. Then I added the printers (Devices and Printers–>Add Printer) that we print to. After doing that the service printed in seconds. If I then removed the printer, it took 4-5 minutes to print.

So I’m guessing without the printer added it has to query the printer and possibly download drivers each time (we are printing to network printers). I’m not exactly sure what the delay is.

Hi Patrick,


Thanks for sharing the details.

When a printer is not installed and you have referenced a printer inside your code, the system will search for respective printer and in case its not installed, it might be attempting to download its drivers and no drivers are found, an error will be generated. You may consider testing the scenario by removing internet/network connect over system running service and see whats the behavior (the API triggers the file print but if no respective printer drivers are found, an error will be thrown).

Hello!

And that is it. We installed the printer local and the problem is gone.

kind regard,
Patrick

Hi Patrick,


Thanks for sharing the feedback. We are pleased to hear that your problem is resolved. Please continue using our API’s and in the event of any further query, please feel free to contact.

A post was split to a new topic: How long does it take to print with printdocumentwithsettings

A post was split to a new topic: Printing PDF using MVC web application takes times