Class Viewer

  • public class Viewer
    extends Object

    PDF Viewer

    Run directly from jar with java -cp jpedal.jar org/jpedal/examples/viewer/Viewer

    There are plenty of tutorials on how to configure the Viewer on our website Support Section.

    If you want to implement your own there are tutorials at : Customizing the Viewer

    We recommend you look at the full viewer as it is totally configurable and does everything for you.

    Fully featured GUI viewer and demonstration of JPedal's capabilities.

    This class provides the framework for the Viewer and calls other classes which provide the following functions:-

    • Values commonValues - repository for general settings.
    • PdfDecoder decode_pdf - PDF library and panel.
    • SwingThumbnailPanel thumbnails - provides a thumbnail pane down the left side of page - thumbnails can be clicked on to goto page.
    • PropertiesFile properties - saved values stored between sessions.
    • SwingGUI currentGUI - all Swing GUI functions.
    • SwingSearchWindow searchFrame (not GPL) - search Window to search pages and goto references on any page.
    • SwingCommands currentCommands - parses and executes all options.
    • Field Detail

      • exitOnClose

        public static boolean exitOnClose
      • closeCalled

        public static boolean closeCalled
    • Constructor Detail

      • Viewer

        public Viewer()
        setup and run client
      • Viewer

        public Viewer​(Accessible rootContainer,
                      String preferencesPath)
        setup and run client passing in parameter that points to the preferences file we should use. preferences file
        rootContainer - Is a swing component that the viewer is displayed inside
        preferencesPath - The path of the preferences file
      • Viewer

        public Viewer​(String prefs)
        setup and run client passing in paramter that points to the preferences file we should use.
        prefs - Full path to xml file containing preferences
    • Method Detail

      • getSearchResults

        public org.jpedal.examples.viewer.gui.swing.SearchList getSearchResults()
        Get the search results from a search performing in the Viewer. This is how users searching from a Viewer object can retrieve results if they wish to use them outside of the Viewer.
        SearchList object containing the current search results list
      • main

        public static void main​(String[] args)
        main method to run the software as standalone application
        args - Program arguments passed into the Viewer.
      • getSwingGUI

        public org.jpedal.examples.viewer.gui.SwingGUI getSwingGUI()
        open the file passed in by user on startup (do not call directly) USED by our tests
        the current gui
      • openDefaultFile

        public void openDefaultFile​(String defaultFile)
        defaultFile - Allow user to open PDF file to display
      • getPdfDecoder

        public org.jpedal.PdfDecoderInt getPdfDecoder()
      • setRootContainer

        public void setRootContainer​(Object rootContainer)
      • loadProperties

        public void loadProperties​(String props)
        Should be called before setupViewer
        props - path to the properties file to load
      • setupViewer

        public void setupViewer()
        initialise and run client (default as Application in own Frame)
      • executeCommand

        public Object executeCommand​(int commandID,
                                     Object[] args)
        Execute Jpedal functionality from outside of the library using this method. EXAMPLES commandID = Commands.OPENFILE, args = {"/PDFData/Hand_Test/crbtrader.pdf}" commandID = Commands.OPENFILE, args = {byte[] = {0,1,1,0,1,1,1,0,0,1}, "/PDFData/Hand_Test/crbtrader.pdf}" commandID = Commands.ROTATION, args = {"90"} commandID = Commands.OPENURL, args = {""}

        for full details see

        commandID - :: static int value from Commands to spedify which command is wanted
        args - :: arguements for the desired command
        any returned value from executed command
      • addExternalHandler

        public void addExternalHandler​(Map<Integer,​Object> newHandler,
                                       int type)
        Allows external helper classes to be added to JPedal to alter default functionality.

        If Options.FormsActionHandler is the type then the newHandler should be of the form org.jpedal.objects.acroforms.ActionHandler

        If Options.JPedalActionHandler is the type then the newHandler should be of the form Map which contains Command Integers, mapped onto their respective org.jpedal.examples.viewer.gui.swing.JPedalActionHandler implementations. For example, to create a custom help action, you would add to your map, Integer(Commands.HELP) -> JPedalActionHandler. For a tutorial on creating custom actions in the Viewer, see
        newHandler - Implementation of interface provided by IDR solutions
        type - Defined value into org.jpedal.external.Options class
      • dispose

        public void dispose()
        run with caution and only at end of usage if you really need