Share this page 

Print a PDFTag(s): IO Open Source


[Windows only]
You can launch the Acrobat Reader to print a PDF to the default printer.

More infos the "unsupported" command-line switches for the Acrobat reader :

http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/intro_to_sdk/DeveloperFAQ.pdf (page 27).

import java.io.IOException;

public class PdfUtils {
  static final String WIN_COMSPEC = System.getenv("comspec");
  static final String WIN_ACROBAT = "acrord32.exe";
  public static void print(String pdf) throws IOException
  {
    String[] commands =
    {WIN_COMSPEC,
     "/c",
     "start",
     WIN_ACROBAT,
     "/t",
     "/h",
     pdf };

    Runtime.getRuntime().exec(commands);
  }

  public static void main(String[] args) throws IOException {
    PdfUtils.print("c:/users/public/temp/test.pdf");
  }
}
Unfortunately, Acrobat Reader stays opened (but minimized because of the /h switch) after the printing operation :-(

You can use a special wrapper to force the closing the Acrobat Reader after the print operation. See http://www.biopdf.com/acrowrap/close_adobe_reader.php (acrowrap.exe).