Friday, July 15, 2011 6:40:51 PM UTC :: Filed Under ASP.NET | C#

At work, I am responsible for an ASP.NET application that allows the user to print PDF files from the server that hosts the web site.  In order to print the PDF files, the web application invokes a process by calling the AcroRd32.exe and passing command line parameters.  For a while, this seemed to be a decent solution, other than the fact that calling Acrobat Reader via the command line is not supported by Adobe

Upon the latest update to the web application, we started having a lot of problems getting the PDF files to print.  After literally spending a week of my time trying to determine what the issue was, I still had no solid clue as to why the PDFs would sometimes print and sometimes wouldn't.  When they didn't print, there was no error in the log file.  I attached a remote debugger to the installed web application and the web application was correctly invoking the Acrobat Reader process and passing-in the appropriate file path and printer name.   What really got me confused is that I could see the AcroRd32.exe process start-up in the server's Task Manager, but no job would land in the print queue.

Then one lucky day, I discovered this article:

Microsoft Support:  How to send raw data to a printer by using Visual C# .NET

I created the test application in the article, sent a test print to a local printer, and sure enough... it works!  And no Adobe Acrobat Reader required!   I ripped-out all reference to Adobe Acrobat in my web application and replaced it with this new code, and then lived happily ever after.

From my limited understanding, the printer must have native PDF support built-in in order for it to be able to print PDFs in this manner.  The two printers I tested were manufactured by Xerox and HP.  I'm assuming that most modern business printers have the ability to print PDFs.

Navigation
On this page....
Search
Archives
<July 2011>
SunMonTueWedThuFriSat
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456
Categories
Contact me
Send mail to the author(s) Contact Todd M. Taylor