Click here to Skip to main content
15,911,896 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
>Hi Everyone,

I want to print multiple pdf document on one click without killing adobe exe.
I tried below code but it prints only first sucessfully but rest of document does not print.

So please any solution will be highly appreciated.

Pushkar

What I have tried:

C#
Process oProcess = new Process();
try
{
	oProcess.StartInfo.FileName = PDFFilePath;
	oProcess.StartInfo.UseShellExecute = true;
	oProcess.StartInfo.CreateNoWindow = true;
	oProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
	oProcess.StartInfo.Verb = "print";
	oProcess.Start();
	if (oProcess.HasExited == false)
	{
		oProcess.WaitForExit(10000);
	}
	Success = true;
}
catch (InvalidOperationException ex)
{
	throw ex;
}
catch (IOException ex)
{
	throw ex;
}
catch (Exception ex)
{
	throw ex;
}
finally
{
	if (oProcess != null)
	{
		oProcess = null;
	}
}
Posted
Updated 29-May-16 15:14pm
v3
Comments
Sergey Alexandrovich Kryukov 29-May-16 17:30pm    
You biggest mistake is oProcess.WaitForExit(10000);
What it timeout would possibly do? You need to start processes in a loop for different files. Waiting for each process would kill the parallelism.
—SA

1 solution

If you have PDF documents already, I dont see why you need to use Adobe to print them, since you dont need a dialogue - why not send the documents directly to the printer ? (see link)

How to programmatically (C# .NET) print a pdf file directly to the printer | vishalsbsinha[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900