SmartJPrint (server edition) - Java API to silent print and convert existing PDF documents from standalone server applications

Silent Print PDF and Convert to TIFF, PostScript documents and images such as PNG, BMP, GIF, JPG/JPEG and more.

NOTE: You DO NOT need any other software to Print, View and Convert your PDF documents.


  • About PDF Server API
  • What archive to download?
  • Typing the URL of your document
  • Run samples
  • Jar Files
  • Silent print PDF
  • Silent printing Parameters
  • Conversion - PDF to TIFF, PostScript, PNG, BMP, GIF, JPEG/JPG and more
  • Conversion - Examples

  • About PDF Server API

    SmartJPrint server edition supports:

  • Printing - of exiting PDF documents
  • Conversion - of PDF files to other file formats and images
  • PDF server APIs lets you silent print of an existing PDF. It lets you convert your PDF to other file formats such as TIFF and Post Script (PS). You can convert your PDF files to image formats such as PNG, GIF, JPG, JPEG, BMP, and more. When converting the PDF to image formats the output images may be produced with a different resolution (smaller or larger than the actul page size) ones. For example, to show a thumbnail image of a page you can create a small image of a page. For clear view of the page, you can create an enlarged picture of a page.

    Your PDF can be a local file or a remote file or a server page that dynamically generates a PDF.

    Back to Top
    What archive to download?

    Visit our website and download server version of the PDF archive. After downloading unzip this ZIP archive to a local folder (let us say c:/pdf/).

    Back to Top
    Typing the URL of your document

    Input an URL and does not matter if the document is located in local file system, in a remote web server or a server program that dynamically generate one. An URL with appropriate URL syntax is all that required for printing or viewing it.

    Examples of typing a local file URL:

  • Window: file:///c:/pdf/sample.pdf or file:/c:/pdf/sample.pdf
  • Mac OS: file:Macintosh HD/pdf/sample.pdf
  • Unix/Linux: file:///tmp/pdf/sample.pdf
  • Examples of typing remote URL:

  • HTTP: http://www.activetree.com/jprint/demo/sample_pdf/sample1.pdf
  • HTTPS: https://www.paypal.com/en_US/pdf/PP_Sandbox_UserGuide.pdf
  • FTP: ftp://ftp.eia.doe.gov/pub/oiaf/1605/cdrom/pdf/ggrpt/057306.pdf
  • Back to Top
    Run samples

    There is an executable script file (.bat and .sh) for each of the demo JAVA sample in the "examples" directory. For Pdf2ResizedPngDemo.java sample there is a Pdf2ResizedPngDemo.bat (for Windows) and a Pdf2ResizedPngDemo.sh (for Unix/Linux) in the installation/ProductDirectory/bin/converter/ directory.

    For running these *.bat or *.sh script files open a command shell, go to the directory where this script are located, then simply type one of the script file name and press enter. It will show you the "Usage" help for further trying the same but with the command line arguments.

    There is a sample PDF file sample1.pdf in the "installation/ProductDirectory/bin" directory.

    Back to Top
    Jar Files

    Include all jar files except the demo jars in your classpath if you are running your own code sample. Otherwise, include all jars including the demo jars in the classpath.

    Back to Top
    Silent printing PDF

    SilentPrintPdf - is the class you use for silent printing of a PDF document.

    Creating a silent printing instance

    /////File: SilentPrintDemo.java//////////////        
    import com.activetree.common.print.SilentPrint;
    import com.activetree.pdfprint.SilentPrintPdf;
          
    public class SilentPrintDemo {
      public static void main(String[] args) {
        //...
        //Silent print instance
        SilentPrint silentPrint = new SilentPrintPdf();
        //...
      }
    }
    //End of file
          
        

    Setting parameters

    Silent print parameters are set by calling setAttribute(String param, Object paramValue) on the printer class.

    Examples of setting parameters

        //default media size
        String paperSize = "(0, 0, 0, 0, 612, 792)";
        silentPrint.setAttribute(SilentPrint.PAPER, paperSize);
        //printer to print
        PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
        String printerName = defaultPrintService.getName();
        silentPrint.setAttribute(SilentPrint.PRINTER_NAME, printerName);
        //auto rotate and center
        silentPrint.setAttribute(SilentPrint.AUTO_ROTATE_AND_CENTER, Boolean.TRUE);
        //page scaling
        silentPrint.setAttribute(SilentPrint.PAGE_SCALING, SilentPrint.FIT_TO_PRINTABLE_AREA);
        //collate
        silentPrint.setAttribute(SilentPrint.COLLATE_COPIES, Boolean.TRUE);
        //copies defaut 1; can make it to N copies
        silentPrint.setAttribute(SilentPrint.COPIES, new Integer(1));
        //debug it
        //silentPrint.setAttribute(SilentPrint.DEBUG, Boolean.TRUE);
        //job name
        silentPrint.setAttribute(SilentPrint.JOB_NAME, "PDFSilentPrint");
        //document
        silentPrint.setAttribute(SilentPrint.DOC_LIST, docList);
        //Add a docListener
        //must have a default constructor for this class.
        silentPrint.setAttribute(SilentPrint.DOC_LISTENER, "demo.activetree.pdfprint.PdfDocListener");
        //doc password protected if any
        silentPrint.setAttribute(SilentPrint.PASSWORD, docPassword);
        //url protection if any
        silentPrint.setAttribute(SilentPrint.URL_AUTH_ID, urlAuthId);
        silentPrint.setAttribute(SilentPrint.URL_AUTH_PASSWORD, urlAuthPassword);
    
        //Now start the process
        try {
          silentPrint.start();
        }catch(Throwable t) {
          t.printStackTrace();
        }
       

    Demo Java source files

    Look at the demo source files under installation/bin/print/ for printing and installation/bin/converter/ for conversion demo samples.

    Silent print PDF bytes[] content

    DOC_LIST parameter is always used for for setting content to be printed. Create a java.util.List object with each element the byte[] content of the document. Follow the examples in the downloaded archive.

    Back to Top
    Silent printing parameters

    Details of the parameter name and its possible values are listed here.

    Back to Top
    Silent printing code samples

    There are several working code samples in the downloaded server archive in the "examples" directory. In the "bin" directory, for each of the code sample there is a Windows batch file (.bat) and an equivalent UNIX/LINUX shell scrip file (.sh) for running it.

    Back to Top
    Conversion - PDF to TIFF, PostScript, PNG, BMP, GIF, JPEG/JPG and more

    Your PDF can be converted to these formats:

    Document formats

  • TIFF with compressions (NONE|PACKBITS|GROUP4|JPEG_TTN2|DEFLATE)
  • PostScript (PS)
  • Image formats

  • PNG
  • GIF
  • BMP
  • JPEG/JPG
  • Back to Top
    Conversion - Examples

    There are some PDF server examples in the downloaded server archive in its "examples" directory. We suggest you to take a look in these Java sample files and if necessary create your own custom server programs.

    All conversion sample code has a corresponding BAT and SH script file in the "bin/converter" directory.

    Back to Top

    Copyright © Activetree, Inc. All rights reserved.
    Web: http://www.activetree.com
    Email: sales@activetree.com
    Tel: +1 408-791-8036 Fax: +1 408-716-8450