Search This Blog

Loading...

Monday, 21 July 2008

Print PDF to any printer

The current implementation of WatchDirectory's Print PDF plugin always prints to the default printer. Here is a small tip if you want to print to another printer.

This is what Adobe has to say on this subject:

The DDE command line parameters for Acrobat and Reader are as follows. These are unsupported but have worked for some developers.

AcroRd32.exe /p filename
- executes the Reader and prints a file
AcroRd32.exe /t path printername drivername portname
- Initiates Acrobat Reader, prints a file while suppressing the Acrobat print dialog box, then terminates Reader.

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. Whatever appears in the Driver Used box when you view 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.

Note: If using Acrobat, substitute Acrobat.exe in place of AcroRd32.exe in the command lines.

The current implementation of WatchDirectory's "Print PDF" plugin passes 2 parameters to Acrobat:
/p - like above: print the pdf
/h - undocumented - do not show Acrobat's window while printing

If you want to print to another printer than the default, you need to use the "Run Any Bat File" plugin (you will find it on "New Task -> Scripting") and use the following batch file to do the printing:

rem you may need to change this, where is acrobat reader?
SET ACRO=C:\Program Files\Acrobat\Reader\AcroRd32.exe
SET TIMEOUT=60
rem if the printername doesn't contain spaces, remove the "quotes"!
SET PRINTER="My Printer"
SET GDPU=%WD_INSTDIR%\GdPUtil.exe



rem check for valid file type
IF "%WD_FILE_E%" NEQ "PDF" (
   %ANNOTATE% Warn "File not printed, only PDF files are supported"
   GOTO :Eof
)

"%GDPU%" -runkill %TIMEOUT% "%ACRO%" /t "%WD_FILE%" %PRINTER%
%ANNOTATE% Info done

Please change the script as needed (printername, location of Acrobat Reader).

Adobe® and Acrobat® are registered trademarks of Adobe.

No comments: