PDF Technology - Java PDF Viewer Tutorial

  • About PDF viewer
  • What archive to download?
  • License key
  • Typing the PDF URL in the viewer
  • Run samples
  • Jar Files
  • Viewer Components
  • Examples
  • Customizing PDF viewer

  • About PDF Viewer

    It has Java PDF viewer components which are just like any other Swing components. Viewer components can be added to your existing Swing UI application. PDF Swing components allow opening a PDF file to view, print, save a copy, convert to a TIFF file, save PDF pages selectively or all to images such as BMP, PNG, GIF, JPG, and JPEG.

    Back to Top
    What archive to download?

    Visit our website and download Viewer archive. Once downloaded unzip this ZIP archive to a local folder (let us say c:/pdf/).

    Back to Top
    License key

    It requires a license key for making it functional. All demo archives are functional using the demo license key "A8EC-73AF-64A9-0375". One of the command line arguments to the .bat (for Windows) or .sh (for Unix/Linux) file might be the license key. To find out what are the command line arguments are required for the sample scripts to work simply type the script and press enter it will show you the "Usage" options.

    Back to Top
    Typing the PDF URL in the viewer

    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/silent_print_pdf_from_browser/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 a executable script file for each of the demo JAVA sample in the "examples" directory. For PdfViewer.java sample there is a PdfViewer.bat in the installation/ProductDirectory/bin/viewer/ directory.
    For running this PdfViewer.bat script file open a command shell, go to the directory where this script is located, simply type this batch file and press enter. Click on the 'Open' menu or toolbar button to select a local PDF file. Alternatively, open your PDF by trying the URL of your document in the entry field and then press ENTER. There is a sample PDF file sample2.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
    Viewer Components

    AtPdfViewPane - is a Java Swing component can be added to your application just like any other Swing components you add to your Java UI application. This class can be customized by deriving one from here. Alternative, you can create an instance of this class and then enable or disable one or more controls, change the controls location, or simply change the icons, text of the controls.

    Back to Top
    Examples

    There are some PDF viewer examples in the PDF viewer archive in the "examples" directory.

  • PdfViewer.java - run (bin/viewer/PdfViewer.bat or .sh) (a PDF viewer frame window)
  • PdfViewerDialog.java - (bin/viewer/PdfViewerDialog.bat or .sh) (a PDF viewer dialog window)
  • PDFViewingBytes.java - (bin/viewer/PDFViewingBytes.bat or .sh) (a frame window opens a PDF from byte[] PDF content)
  • There might be more examples in this directory location
  • Back to Top
    Customizing PDF viewer

    AtPdfViewPane class is fully customizable to create your own UI by changing existing icons, menus, toolbar buttons, adding new menu and toolbar buttons or changing the layout of the controls.

    Customization examples:

  • HowToUsePdfViewPane.java (run bin/viewer/HowToUsePdfViewPane.bat or .sh )
  • HowToUsePdfViewPane2.java (run bin/viewer/HowToUsePdfViewPane2.bat or .sh )
  • HowToUsePdfViewPane3.java (run bin/viewer/HowToUsePdfViewPane3.bat or .sh)
  • Back to Top

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