Printing PDF from the Command Line using the Adobe PDF Library with Datalogics Extensions

Sample of the Week:

Part of my job as the Evangelist at Datalogics is to scour the Acrobat SDK Forums and try to help people understand how to use the Adobe PDF Library instead of Adobe Acrobat or Reader when they need Acrobat functionality… but they need it to run on a server or via the command line.

One of the questions that I still come across with alarming frequency and is the cause of some of the most frustrated complaints aimed at Adobe relates to command line printing from Reader. It seems that many enterprises have build mission-critical, server-based functionality around unsupported features in Adobe Reader and then get in trouble when Reader updates or Adobe changes how Reader works.

Adobe Reader just wasn’t engineered for this use case.

Instead, use the Adobe PDF Library, the same technology that Adobe uses to build Acrobat and Reader. The Gist below demonstrates the use of the the Adobe PDF Library with Datalogics Extensions to print a PDF file without any user dialogs. The code contains comments on how to set some common print parameters.

To get started with printing PDF from the command line in a reliable and consistent way, download this Gist and request an evaluation copy of Adobe PDF Library from Datalogics.


Share this post with your friends

Share on facebook
Share on twitter
Share on linkedin

2 thoughts on “Printing PDF from the Command Line using the Adobe PDF Library with Datalogics Extensions”

  1. An exception of type ‘System.ApplicationException’ occurred in Datalogics.PDFL.dll but was not handled in user code
    Additional information: Access is denied.
    I’m getting this when I get to the line:
    here is my code:
    using (PrintUserParams userParams = new PrintUserParams())
    userParams.DeviceName = “HP LaserJet Pro MFP M521dn UPD PS”;
    userParams.DriverName = “winspool”;
    userParams.PortName = “Ne03”;
    I’m stumped. Thanks for any insight.

  2. The PortName is likely incorrect; you may be able to just specify the DeviceName, but you might want have user.Params.PosePrintDialog(doc); where you currently have //userParams.UseDefaultPrinter(doc);
    select the printer manually, and then read the DeviceName, DriverName, and PortName from userParams to be certain you are using the correct values when hard-coding them into your code.

Leave a Comment

Your email address will not be published. Required fields are marked *