Print Multiple PDFs

Print Multiple PDFs

Forum member · Jun 1, 2012
Hello, I wanna print multiple pdf’s (1646 pdf’s). I add the pdf’s to the printjob but at pdf 509 it crashed (DocumentLoadException). How can i more pdf’s add to the printjob?

Re: Print Multiple PDFs

Support · Jun 1, 2012
Hello, Can you please try using the latest DynamicPDF PrintManager for .NET product dll file in your application and see if it works for you? You can download the latest DynamicPDF PrintManager for .NET product MSI from our CustomerArea: http://www.dynamicpdf.com/CustomerArea by logging into it using your product serial number Install the latest DynamicPDF PrintManager for .NET product in your system. Remove reference for the old dll file and reference the latest in your application. If you are evaluating the product then you can download the latest DynamicPDF PrintManager for .NET product from our website at: http://www.dynamicpdf.com/Products/DynamicPDFPrintManagerforNET/Download.csp . If you continue getting the error even after using the latest dll file then please try the below code. One of the overloads of the Add method takes an InputPdf object as a parameter, so instead of passing a file path you can construct an InputPdf object and use it in the Add method. In order to construct the InputPdf object we used a ReadFile() method that takes a file path and returns the byte array of the file which can be passes as a parameter to the InputPdf constructor. String[] files = Directory.GetFiles(@"F:\temporary\PDFs\"); PrintJob printJob = new PrintJob(Printer.Default); for (int i = 0; i < 700 ; i++) { InputPdf pdf = new InputPdf(ReadFile(files[i])); printJob.Pages.Add(pdf); printJob.Print(); printJob = new PrintJob(Printer.Default); pdf.Dispose(); } Code for ReadFile method. public static byte[] ReadFile(string filePath) { byte[] buffer; FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); try { int length = (int)fileStream.Length; // get file length buffer = new byte[length]; // create buffer int count; // actual number of bytes read int sum = 0; // total number of bytes read // read until Read method returns 0 (end of the stream has been reached) while ((count = fileStream.Read(buffer, sum, length - sum)) > 0) sum += count; // sum is a buffer offset for next reading } finally { fileStream.Close(); } return buffer; } Thanks, ceTe Software Support Team.

Re: Print Multiple PDFs

Forum member · Jun 8, 2012
Hello, It works great. Thank you