I Have a problem in Windows application in .net. I have a PDF file which is stored in my local drive. At run time i need to print that PDF Document using C#. Can you help me out from this problem ?

Help appreciated..
thanks in advance..

Hi, I spent a good deal of time researching the subject this morning, and this is what I have learned...

There are only three ways to do this that I could find:

  • DDE
  • Command Line Parameters
  • Plug-In (Purchased or Licensed by Adobe)


There are third-party plug-in's available for a cost, but I did not research these and I don't know if you must also buy Adobe Acrobat.

You can also buy the Adobe Acrobat software and create a plug-in for your application that has to be approved and licensed by Adobe, which may or may not decide to approve what you are doing. If this option apeals to you, contact Adobe and begin a discussion.

DDE (Dynamic Data Exchange)

This technology is as old as Windows itself. As far as I can determine, it is still supported by Adobe for backward compatibility, but I did not check any version history information for the Reader to ensure this is factual. There use to be an open source project (NDde) on CodePlex that provided a library interface to facilitate DDE development, but they have removed the download link. This library might still be available somewhere, but I did not pursue this. Here are some DDE links I ran into:

Small ReaderWrapper class written in CPP

DDE Reader example using NDde

Another Reader example using NDde, with very informative links inside...

DDE Information (FAQ) - Client and Server DDE libraries written in VB

Command Line Parameters

The command line parameters open up the Reader, print, and then close, and they may not work with all releases of the free Reader. I've read about developers having trouble using these in version 6 or 7 (cannot remember). In addition, Adobe does not support them (in their own words):

AcroRd32.exe /p filename

AcroRd32.exe /t path printername drivername portname

However, having said that, I downloaded an open source C# library called PDFsharp, which uses them and it printed OK. I am running AcroRd32.exe v9. Here is how I did it:

  1. Download the library: PDFsharp download page I downloaded: PDFSharp-MigraDocFoundation-1_30.zip
  2. Add the "PdfSharp.csproj" to your solution
  3. Add a reference to PdfSharp inside your application
  4. Call the print pdf class:

    PdfSharp.Pdf.Printing.PdfFilePrinter pdoc = new PdfSharp.Pdf.Printing.PdfFilePrinter(fName);
    PdfSharp.Pdf.Printing.PdfFilePrinter.AdobeReaderPath = @"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe";
    PdfSharp.Pdf.Printing.PdfFilePrinter.DefaultPrinterName = "Samsung ML-1740 Series";

The library does a lot more than print, but I wanted to check it out and since it worked, I figured I would pass it along. It also contains many C# examples of manipulating PDF documents.

Hope this helps. Cheers!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.