We have logic to convert HTML to PDF, Once the conversion is done we are sending this PDF files to network printers(which are shared over the network and added on the server) using a self hosted windows service. Below is the code we used from printing
- Code: Select all
foreach (string fileName in fileArray)
{
FileInfo f = new FileInfo(fileName);
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(f.FullName);
doc.PrintSettings.PrinterName = HttpUtility.UrlDecode(printerName);
doc.PrintSettings.Copies = copies;
doc.PrintSettings.DocumentName = Path.GetFileNameWithoutExtension(f.Name);
PaperSize paperSize = new PaperSize();
System.Drawing.SizeF size = doc.Pages[0].Size;
paperSize.Width = Convert.ToInt16(size.Width);
paperSize.Height = Convert.ToInt16(size.Height);
paperSize.RawKind = (int)PaperKind.Custom;
doc.PrintSettings.PaperSize = paperSize;
doc.PrintSettings.SetPaperMargins(0, 0, 0, 0);
doc.Print();
}
Now the problem is if a single user is trying to print then printing is happening quickly in less than 5 seconds. But if there are multiple users who are concurrently working on this then print is getting delayed by 20 to 30 seconds( each user will print to different printers which are added over the server) . Is this anything related to threads that gets created when doc.print is invoked? Is there anything that we can do before doc.print is invoked to increase performance?
Server Info:
Server Version : Windows Server 2016 Standard
Type : 64 bit OS
RAM : 8GB
Print Info:
Input Doc: PDF
Time Delay : 20+ seconds when multiple users are using though the print is going to different printers
Is there any workaround to increase the print speed when multiple people invoke doc.print? Please let me know if you require any other additional info.