0

I currently have a C# console application that prints PDF documents. My problem is that it take a lot of time for the pdf to get spooled and eventually printed. Even when I set the printer driver to Direct Printing it still takes some time.

I am looking for ways to speed up the printing process. I would appreciate any suggestions. I will be willing to look at Free or inexpensive nuget packages. Or any Silent methods of printing. I have tried using the adobe dll but that opens up a window, which I am trying to avoid.

I am using the code below to print the PDF

            var printer = _appConfiguration.GetValue<string>("PRINTERS:RDLReceipt1");
            var filename = @"C:\\TEMP\\reciept-" + barcode + ".pdf";
            var nopages = 0;
            using (var pdfDocument = new PdfDocument(filename))
            {
                nopages = pdfDocument.PageCount;
                using (var printDocument = pdfDocument.GetPrintDocument())
                {
                    printDocument.PrinterSettings.PrinterName = printer;
                    printDocument.Print();
                }
            }
Stanton Roux
  • 141
  • 1
  • 14
  • What is the size of the file and how many pages are there? Do you print on a local or remote device? What operating system and version? What machine processor and ram? What technology do you use to print i.e. PdfDocument comes from what library? https://stackoverflow.com/questions/5566186/print-pdf-in-c-sharp –  Aug 11 '21 at 11:56
  • The PDF's Range from 40kb - 600kb. 1 - 30 pages. I print to a remote thermal printer. The software runs on windows server 2019 standard, with 20 gb of RAM and 8 CPU's. PDFDocument is a IronPDF method. A third part nuget package. – Stanton Roux Aug 11 '21 at 12:03
  • Remote adds delay... How many MHz CPU? I forgot to ask: does the PDF have a lot of images? How about printing with Acrobat, Word or a browser? –  Aug 11 '21 at 12:04
  • The pdfs are just text. When I print to the printer from acrobat on the printer server it prints immediately. CPU is 2.3 GHZ. A very serious machine. I have gone through the thread you sent me before and have tried most of those packages none of them worked for me. – Stanton Roux Aug 11 '21 at 12:22
  • Have you tried using another .NET library? https://nugetmusthaves.com/Package?q=pdf+print –  Aug 11 '21 at 12:24
  • Yes I looked at all of those and they average $700. – Stanton Roux Aug 11 '21 at 12:29
  • Indeed... No open-source or more affordable in the list? What about that? https://www.google.com/search?q=c%23+github+print+pdf –  Aug 11 '21 at 12:32
  • Thanks will give it a try – Stanton Roux Aug 11 '21 at 12:35
  • You may check Spire.PDF: https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Print/How-to-print-PDF-document-in-C.html – Dheeraj Malik Aug 13 '21 at 01:32

0 Answers0