batch printing pdf files

  • Thread starter Thread starter David Cho
  • Start date Start date
D

David Cho

I loop through the code that looks like this to batch a set of pdf
files.

Process command = new Process();
command.StartInfo.FileName = "AcroRd32.exe";
command.StartInfo.Arguments = "/p /h " + pdfFileName;
command.StartInfo.RedirectStandardOutput = true;
command.StartInfo.UseShellExecute = false;
command.Start();

The problem is, the order in which the documents are printed is very
important. But it seems like Acrobat Reader and the printer scramble
the order.

Here is a very strange thing. Right after command.Start(), I tried

command.StandardOutput.ReadToEnd();

It USED TO WORK. And then out of the blue, it prints the document and
just hangs until I kill Acrobat Reader.

Adding

Thread.Sleep(10000);

Will make the order right, but only to a degree. The order is just less
scrambled, which is not good enough.

So please help.
 
You will need to wait for each process to finish before starting a new
priting process.

I would make the following changes
Process command = new Process();
command.StartInfo.FileName = "AcroRd32.exe";
command.StartInfo.Arguments = "/p /h " + pdfFileName;
command.StartInfo.RedirectStandardOutput = true;
command.StartInfo.UseShellExecute = false;
command.Start();
command.StandardOutput.ReadToEnd();
command.WaitForExit();
 
Back
Top