Click here to Skip to main content
14,979,837 members
Articles / General Programming / Printing
Posted 23 May 2016

Tagged as


11 bookmarked

How to Silently Print PDFs using Adobe Reader and C#

Rate me:
Please Sign up or sign in to vote.
4.81/5 (9 votes)
23 May 2016CPOL2 min read
This is an alternative for "How to Silently Print PDFs using Adobe Reader and C#"


If you want to print a PDF document to another printer than the default printer, you need to use some other switches than in the original article.


As I have more than one printer in my network and Windows 10 likes to change the default printer every time I change the properties of a printer, I needed to make sure that the PDF document was printed with one specific printer.

I got tired of PDF documents printed on photo paper.

Using the Code

This is only a code snippet and assumes that there is a variable containing the path to the PDF file.

string pathPdf = "...";  // The path to your document

And this is the full code:

ProcessStartInfo infoPrintPdf = new ProcessStartInfo();
infoPrintPdf.FileName = pathPdf;
// The printer name is hardcoded here, but normally I get this from a combobox with all printers
string printerName = "Samsung M262x 282x Series";
string driverName = "printqueue.inf";
string portName = "SEC30CDA792D770";
infoPrintPdf.FileName = @"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe";
infoPrintPdf.Arguments = string.Format("/t {0} \"{1}\" \"{2}\" \"{3}\"", 
    pathPdf, printerName, driverName, portName);
infoPrintPdf.CreateNoWindow = true;
infoPrintPdf.UseShellExecute = false;
infoPrintPdf.WindowStyle = ProcessWindowStyle.Hidden;
Process printPdf = new Process();
printPdf.StartInfo = infoPrintPdf;

// This time depends on the printer, but has to be long enough to
// let the printer start printing

if (!printPdf.CloseMainWindow())              // CloseMainWindow never seems to succeed
    printPdf.Kill(); printPdf.WaitForExit();  // Kill AcroRd32.exe

printPdf.Close();  // Close the process and release resources

How to Find the Printer Variables

In the document Acrobat FAQ on page 27, this information can be found:

AcroRd32.exe /t path "printername" "drivername" "portname"

— Initiates Adobe Reader and prints a file, whose path must be fully specified, while suppressing the Print dialog box. The four parameters of the /t option evaluate to path, printername, drivername, and portname (all strings).

  • printername — The name of your printer.
  • drivername — Your printer driver’s name, as it appears in your printer’s properties.
  • portname — The printer’s port. portname cannot contain any "/" characters; if it does, output is routed to the default port for that printer.

The steps below might be a bit simplistic for some, but maybe not for everyone.

Note: I am using Windows 10, the exact steps might differ on other versions of Windows.

1. Open the Control Panel and select View devices and printers

Right-click on the wanted printer to show the context menu:

Printer Context Menu

1.1. To start with, select Printer Properties

Printer Properties Dialog

On the General tab, you can find the printer name.

1.2. Select the Ports tab and then click on Configure Port

Port Tab

Port Name

Now you have the port name.

1.3. You can now close the dialogs.

2. Driver Name

The last information to be found is the driver name. On Windows 10, I found it to be a bit tricky and it is very possible there is a much easier way. Right-click on the printer again, but this time select Properties at the very bottom.

2.1 In the dialog that opens, select the tab Hardware

Properties - Hardware

2.2 Click the button Properties to show the next dialog and select the tab Details
2.3 Select the property Inf Name in the combo box, and voilà; there is the last piece of information.

Properties - Details

The value is the printer driver.


  • First release of the tip


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

George Jonsson
Philippines Philippines
I have worked with mobile phone testing in manufacturing for 20 years.
Originally from Sweden, but moved to China in 2012.
At the moment I am on a sabbatical year in the Philippines.

Over the years I have used various programming languages such as Pascal, C, C++, C#, SQL, XML, XSLT.

Comments and Discussions

QuestionIt opens the Adobe Reader. Pin
Member 1159685126-Sep-19 2:31
MemberMember 1159685126-Sep-19 2:31 
QuestionNot working in IIS Pin
Anand Solomon1-Feb-19 0:57
MemberAnand Solomon1-Feb-19 0:57 
QuestionCan not wait for the message termination / completion or print failure Pin
Member 1172138925-May-16 9:12
MemberMember 1172138925-May-16 9:12 
GeneralRe: Can not wait for the message termination / completion or print failure Pin
George Jonsson25-May-16 12:28
professionalGeorge Jonsson25-May-16 12:28 
PraiseVery helpful for my current project Pin
SardaX24-May-16 23:43
professionalSardaX24-May-16 23:43 
GeneralRe: Very helpful for my current project Pin
George Jonsson25-May-16 0:57
professionalGeorge Jonsson25-May-16 0:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.