i need to print a pdf file, a standar print, other pdf file, other standar print, and so on.
But, when i sent to the printer the sheets are mixed.
i desire:
PDF
PrintPage
PDF
PrintPage
PDF
PrintPage
but, i got (for example):
PDF
PDF
PrintPage
PrintPage
PrintPage
PDF
I’m using the following code to achive the task:
while( ... ) {
ProcessStartInfo starter = new ProcessStartInfo("path to acrobt32.exe", "/t mypdf001.pdf");
starter.CreateNoWindow = true;
starter.RedirectStandardOutput = true;
starter.UseShellExecute = false;
Process process = new Process();
process.StartInfo = starter;
process.Start();
PrintDocument pd = new PrintDocument();
pd.DocumentName = "Work";
pd.PrintPage += new PrintPageEventHandler(pd_PrintPageHandler);
pd.Print();
}
Any help will be welcome. thanks.
I cannot fully understand the issue from this small example but my guess is that the
pd.Print()method is asynchronous.You want to make the printing synchronous. The best way would be to wrap the code in a function and call that function from the
pd_PrintPageHandlerwhich I assume is called when the page gets printed.A quick example to show what I mean,
and in the
pd_PrintPageHandlermethod, call thisprintPagefunction with the next PDF file.