Hi All,

I need to find a way to automatically print a PDF file from my Windows Application in C#.

Currently I can invoke the following from the command line:
"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" /p /h "C:\Test.pdf"

This will silently print the PDF file but will keep Acrobat Reader open (but minimized) after the printing.

It's critical that I close Acrobat Reader after the printing... Any ideas?

Thanks :)

How? And how can I be sure that its process has finished printing? (I don't want to kill the process and have the printing stopped)
Thanks for the reply :)

I didn't go you well but why you didn't develop application to print pdf files?
anyway, it is not mean you terminate acrobat reader process that, print process will stop. as this print not handled by acrobat reader (as I understand)

Hi All,

I need to find a way to automatically print a PDF file from my Windows Application in C#.

Currently I can invoke the following from the command line:
"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" /p /h "C:\Test.pdf"

This will silently print the PDF file but will keep Acrobat Reader open (but minimized) after the printing.

It's critical that I close Acrobat Reader after the printing... Any ideas?

Thanks :)

I have tried with this code, its working well, but its printing only 1 page not second one, i want to print more than 1 page automatically, i appreciate any one help.

Regards
Ram.

The Adobe site says to use: acrord32.exe /t "printername"

You can also specify the driver and port in the next two params, but I've found it works fine without them if the printer has been "installed". After v4, the reader process remains after being invoked. You could kill it as one poster suggested. In my case I am going to just try to leave it running... it isn't hurting anything and since it is on a server nobody will ever see it (as long as multiple copies don't get started.)

* /n - Launch a new instance of Reader ever if one is already open
* /s - Don't show the splash screen
* /o - Don't show the open file dialog
* /h - Open as a minimized window
* /p <filename> - Open and go straight to the print dialog
* /t <filename> <printername> <drivername> <portname> - Print the file the specified printer.

Bether to use CLPrint on BatchPDFPrint CLPrint have many other options and there is no need for acrobat reader.
I hope that helps.

//Namespaces needed
using System.Diagnostics;

public bool FindAndKillProcess(string name)
{
	//here we're going to get a list of all running processes on
	//the computer
	foreach (Process clsProcess in Process.GetProcesses()) {
		//now we're going to see if any of the running processes
		//match the currently running processes by using the StartsWith Method,
		//this prevents us from incluing the .EXE for the process we're looking for.
		//. Be sure to not
		//add the .exe to the name you provide, i.e: NOTEPAD,
		//not NOTEPAD.EXE or false is always returned even if
		//notepad is running
		if (clsProcess.ProcessName.StartsWith(name))
		{
			//since we found the proccess we now need to use the
			//Kill Method to kill the process. Remember, if you have
			//the process running more than once, say IE open 4
			//times the loop thr way it is now will close all 4,
			//if you want it to just close the first one it finds
			//then add a return; after the Kill
			clsProcess.Kill();
			//process killed, return true
			return true;
		}
	}
	//process not found, return false
	return false;
}

Taken from: http://www.dreamincode.net/code/snippet1543.htm


==================================================================== (edit)

So eh,

FindAndKillProcess("AcroRd32.exe");

Edited 6 Years Ago by chococrack: n/a

What I ended up using was QuickPDFLibrary by Debanu (www.quickpdflibrary.com). $249 for an unlimited, royalty free license. It's been installed in production at an ExxonMobil site now for 6 months with no complaints. Adobe has a similar solution for sale but they wanted $5,000 per site, while QuickPDFLibrary was a one time $249 and we can install it as many times as we please.

In case anyone was wondering, yes I did the process kill first. For some reason as time went on, the printing kept taking longer and longer, and the process kill was killing AcroRd32 before the print was fully spooled, which aborted the job. I had a configurable timeout, so I'd log in and boost the timeout. A week or two later I'd get called that it was happening again... it just kept increasing its time to spool for the same printout (we are talking a period of 3 months). So we started looking for a real solution and we contacted both Adobe and Debanu. After testing a trial of Debanu's solution we didn't bother to go any farther than getting a quoye from Adobe.

This article has been dead for over six months. Start a new discussion instead.