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.

Thu Mar 29, 2018 2:14 am

Hi,
We are evaluating the software and I have created a small printing application using C#. The problem I am having is that the printing of the pdf file is very slow, it takes more than one minute per page. If I open the file and print it to the same printer using adobe, the speed is ok, it is only when I print it from the C# application. Here is the code I have, I extract it from the samples.

public string PrintWithDialogSpire(string fileToPrint)
{
string PrinterName = _printerName;
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(fileToPrint);
PrintDialog dialogPrint = new PrintDialog();
dialogPrint.AllowPrintToFile = true;
dialogPrint.AllowSomePages = true;
dialogPrint.PrinterSettings.MinimumPage = 1;
dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
dialogPrint.PrinterSettings.FromPage = 1;
dialogPrint.PrinterSettings.ToPage = doc.Pages.Count;
dialogPrint.PrinterSettings.PrinterName = PrinterName;

if (dialogPrint.ShowDialog() == DialogResult.OK)
{
doc.PrintSettings.SelectPageRange(dialogPrint.PrinterSettings.FromPage, dialogPrint.PrinterSettings.ToPage);
doc.PrintSettings.PrinterName = dialogPrint.PrinterSettings.PrinterName;

doc.Print();
return _printerName;
}
else
{
return "Error from printer dialog";
}

I also updated all the printers drivers, but I didn't work. Please help. Thanks.

Sandra.

sflechas
 
Posts: 5
Joined: Tue Mar 27, 2018 11:47 pm

Thu Mar 29, 2018 8:37 am

Dear Sandra,

Thanks for your inquiry.
If you were using an older version, I would suggest upgrading to the latest one (Spire.PDF Pack(Hot Fix) Version:4.3.14) to have a test. If the issue still happens, please provide your input Pdf file and tell us your printer name to help us better investigate it. You could send it to us via email support@e-iceblue.com.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Thu Mar 29, 2018 3:09 pm

Hi,
I just sent an email with that information. Please let me know what you find, thank you!
Sandra.

sflechas
 
Posts: 5
Joined: Tue Mar 27, 2018 11:47 pm

Fri Mar 30, 2018 2:49 am

Dear Sandra,

Thanks for your sharing.
I respectively tested your Pdf file with the Microsoft XPS Document Writer and HP LaserJet P1007, but both of them only cost around 7000ms to finish the printing. Sorry we don’t have the same printer Zebra ZT410 (203 dpi) as yours, would you please change another printer (such as Microsoft XPS Document Writer) to have a try? If the speed is still slow, please provide your OS information (e.g. windows 7, 64-bit), region and language setting (e.g. China, Chinese) along with the print time to help us further invetsigate it.
Besides, the deprecated PrintDocument class has alternative in the new version, please refer ro below code to remove the printing progress.
Code: Select all
doc.PrintSettings.PrintController = new StandardPrintController();
doc.PrintSettings.SelectPageRange(dialogPrint.PrinterSettings.FromPage, dialogPrint.PrinterSettings.ToPage);
doc.PrintSettings.PrinterName = dialogPrint.PrinterSettings.PrinterName;

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Fri Mar 30, 2018 2:58 pm

Hi Nina,
I replaced the code and the spooling time reduced significantly using the StandardPrintController, I compared it to the Microsoft XPS printer and it took a few seconds longer. Now we started to test bigger files to review the speed, and the problem we are having is that the spooling locks down the application. I will send you a test file on the email. Is there a way to let the spooling happen in the background? so that the users can continue the operation without having to wait for the spooling to finish?

Thank you.

Sandra.

sflechas
 
Posts: 5
Joined: Tue Mar 27, 2018 11:47 pm

Mon Apr 02, 2018 7:53 am

Hello,

Thanks for your feedback and sorry for late reply as weekend.
Microsoft provides the BackgroundWorker Class which allows you to execute a time-consuming operation asynchronously in the background. You could refer to below link for detailed information.
https://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.110).aspx

Besides, there is another way which can make the print process more quick, please find the attached XpsPrintHelper class and use below code to have a test.
Code: Select all
MemoryStream ms = new MemoryStream();
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("W00037278.pdf");
doc.SaveToStream(ms, FileFormat.XPS);
ms.Position = 0;
XpsPrint.XpsPrintHelper.Print(ms, "Microsoft XPS Document Writer", "Print", true);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Thu Apr 05, 2018 9:34 pm

Hi Nina,
Thank you for your email. Sorry about the delay answering as I was off for a few days. I had a chance to test it and it the printing is working much faster. We are doing more testing and we'll let you know if we run into any problem.
Best Regards,
Sandra

sflechas
 
Posts: 5
Joined: Tue Mar 27, 2018 11:47 pm

Fri Apr 06, 2018 2:27 am

Dear Sandra,

Thanks for your feedback.
Just feel free to contact us if you encounter any problems.
Have a nice day!

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Mon Apr 09, 2018 4:53 pm

Hi Nina,
We continued testing the print out of the reports using the memory stream and the characters are not correct. I emailed you a photo of the printout. When we don't use the memory stream the characters print ok, we had to disable the memory stream but it still takes a long time to print large files. Please let us know what else can we try.
Thank you,
Sandra Flechas.

sflechas
 
Posts: 5
Joined: Tue Mar 27, 2018 11:47 pm

Tue Apr 10, 2018 6:25 am

Dear Sandra,

Thanks for your feedback.
I did notice the incorrect characters issue. Sorry for your inconvenience caused. Currently, I’m afraid there is no other good ways to improve the speed of print. One approach you could try is to use the BackgroundWorker class to execute the printing operation asynchronously in the background. Here I made an example demo for your kind reference. And this documentation contains more information: https://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.110).aspx
http://www.e-iceblue.com/downloads/attachment/BackgroundWorkerDemo.zip

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Mon Apr 16, 2018 8:33 am

Hello,

Greetings from E-iceblue.
Is my suggestion helpful to you?
Thanks in advance for your valuable feedback and time.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Wed Jun 23, 2021 2:59 am

Hi Nina,
I encountered the same problem. I tested the solution using memory stream, and the overall time spent did not change much, but I noticed that the save to momery stream step took about 1 second.
I want to know if there is a way to convert the pdf document into the file format required for printing in advance,
When start printing, only need to send the data to the printer, which should greatly increase the processing speed.

Thank you,
Steven Gao.

topsailgao
 
Posts: 4
Joined: Wed Jun 23, 2021 2:27 am

Wed Jun 23, 2021 6:11 am

Hello Steven,

Thanks for your post.
I'm sorry that our Spire.PDF does not support the feature you describe. Regarding the printing time spent issue, could you please provide your test PDF file and tell us how long it took to print it on your side? Then we will do further investigation to see if it can be optimized. You could send your file to us (support@e-iceblue.com) via email. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Jun 29, 2021 10:53 am

Hello Steven,

Greetings from E-iceblue!
Has your issue been resolved? Any feedback will be greatly appreciated.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Jun 16, 2023 6:08 am

I tried many solutions online , but finally solved it by printing your file as an image.

Grigg23DC
 
Posts: 1
Joined: Fri Jun 16, 2023 6:04 am

Return to Spire.PDF