I’m having trouble many PDF files in the order that I send the print command using the following code:
For i As Int32 = 1 To qtyToPrint Step 1
'calls the process for the printing of the pdf files
Dim myProcess As Process = New Process
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.FileName = fileToPrint
myProcess.StartInfo.Verb = "Print"
myProcess.StartInfo.UseShellExecute = True
myProcess.Start()
myProcess.WaitForExit()
Next
It prints just fine other than it not being in the correct order. The only way I managed to get it in the correct order is by adding a timer and checking to see if there are any jobs in the print queue, which really slows down the printing process, especially when creating 500+ print jobs.
I was wondering if there is a better way to print these files, to where it will print fast and still be in order. A couple things I have in mind, but not sure if possible, is to create a text file or XML file that has the list of files to print and the quantity and queue the printer off that list or to convert PDF files to XPS documents and then using PrintQueue class to add the XPS file as a print job.
Any help would be appreciated!
A better option may be to use a PDF library to combine all of the pdfs into a single file and then printing that single file through the library or using this same method. This way you only have one print job and you control the order the documents are added to the large PDF.