Update: Please check out the other PDF related links in the sidebar as well.
Some horrors are erased!! Gasp !!
I came across the Adobe Acrobat 7.0 Browser Control Type Library that could be used to display and print PDF files on desktop (Windows forms) applications [I haven’t explored utilizing this in a webpage, so that will have to wait]. This is really good stuff for some people, for it is an ActiveX control that you could utilize to automate certain PDF-related actions, instead of relying on the AcroRd32.exe process commandline options or DDE messaging (or worse – Win32 programming).
However, every approach has it’s pitfalls.
And someone’s already had a problem –
Bah. I can’t believe that Adobe hasn’t stepped up to hand out a library that will print any PDF with all of the printer settings available to be changed. (You apparently can create an Interop around their Acrobat TypeLib, but its features are limited and it can only print to the default printer.)
Oh well, that’s why folks can charge lots of money for libraries I guess.
And if you have funds, then take this advice from an ex-Adobe employee a bit seriously, for he says –
I can give ya a little info on this as a former Adobe Employee and specifically dealing with Acrobat. They do have a SDK that allows you to work with PDFs but its not free, it does work in both managed and unmanaged code and they give some good examples done in C# and VB.net but here again its not free. I would look to some of the free PDF stuff and that may work but this is workable if you have the SDK because you can actually create a PDF object and load in that PDF and then use c# to print it like you would anything else.
Here’s the CodeProject article utilizing the Adobe Acrobat 7.0 ActiveX object for communicating with Acrobat Reader, along with the .Net example utilizing the Browser Type Library that is described in the comments.
Ok, want to know more about this library ? Hop on and download the Adobe Acrobat Inter-Application Communication (IAC) Reference from the Adobe site (pdf download). The Acrobat Browser Type Library is provided by the AxAcroPDFLib.AxAcroPDF object. This should be suitable for most of your needs. You can access it by adding a reference to AcroPDF.dll (that resides in the ActiveX directory under the Acrobat application directory) in your IDE environment.
- If you dont want to display the PDF document in a Windows Forms application, then you’ll have to set the ‘Visible’ property to false. And if you want to send the PDF file directly to the printer, then you could use one of the methods provided by the control for that purpose – Print, PrintAll, PrintAllFit, PrintPages, PrintPagesFit. That should be suitable for your silent print needs in most cases.
- You could experience problems when you have to print to the default printer. The default printer seem to be determined by Acrobat when it is loaded, and not by Windows. So changing the default printer mid-way through your application’s runtime might cause unexpected behavior.
- It is impossible to “name” / “determine” the printer that is used to print the document. Unless you don’t want the user to access all the printer settings that could change the workflow, the only solution is to use the PrintWithDialog method (which is used to present the Acrobat Print Dialog Box that allows the user to make changes to the number of copies to be printed, or print to a file).
And to help people searching for solutions to common problems involving Adobe Acrobat (even Reader), I’m posting a link to Experts Exchange’s set of time-tested Adobe Acrobat solutions.