On my machine, when selecting multiple PDF documents in Windows Explorer, right clicking and choosing Print, Adobe Acrobat Reader is opened minimized and all documents are silently sent to the printer.
I want to do the same as Windows does, but how is it done?
I am using ProcessStartInfo with the PrintTo verb, as you can see in a previous question. Unfortunately, this is everything but silent, and I am having big problems when printing more than one document. How do I know when the application (typically Adobe Reader) is done printing? If starting several printTo processes in a row, one document seems to open before the previous is finished printing.
I would like to avoid hard coding Adobe Reader, because some of my users have exchanged it for Foxit Reader or others.
I don’t know if you can do it with other PDF viewers in such a way that those viewers are plug-and-play replacements for Adobe Reader. You’ll probably have to tailor it to each program you want to support. It’s not so difficult to have Reader on one’s system, really, if it’s necessary to perform a job and most computers come with it preinstalled.
The first thing you have to know is that when you tell it to print via that verb, via either code or the Explorer context menu, you are doing something like this:
Note the arguments: /p (tells it to print) and /h (start minimized).
There’s another option. The Adobe Developer FAQ ( http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/intro_to_sdk/DeveloperFAQ.pdf ) states that this command line works per-file:
The document specifies that this initiates Adobe Reader and prints a file, whose path must be fully specified, while suppressing the Print dialog box. (Copy-pasted from Developer FAQ.)
There is also an option /n which “launches a separate instance of Acrobat or Adobe Reader, even if one is currently open.” (Developer FAQ again.) That could be used to run multiple print jobs in parallel, I imagine.
I found yet another command line reference at: Adobe Reader Command Line Reference
So basically, you could iterate your list of PDFs, and for each one start a new print process with a Process.Start call and wait for it to close via a Process.WaitForExit. This will make your program appear to hang and I hate when programs hang while they perform operations, so you should really do this in a cancellable BackgroundWorker that reports progress and still leaves your GUI somewhat interactive.