Class Viewer
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 Summary
FieldsModifier and TypeFieldDescriptionstatic booleanWhether theViewerCommands.EXITcommand exits the JVM after closing the Viewer. -
Constructor Summary
ConstructorsConstructorDescriptionViewer()setup and run clientsetup and run client passing in paramter that points to the preferences file we should use.Viewer(Accessible rootContainer, String preferencesPath) setup and run client passing in parameter that points to the preferences file we should use. preferences file -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExternalHandler(Map<Integer, Object> newHandler, int type) Allows external helper classes to be added to JPedal to alter default functionality.static voidrun the viewer in debug modevoiddispose()run with caution and only at end of usage if you really needexecuteCommand(ViewerCommands command, Object... args) Execute Jpedal functionality from outside the library using this method.Returns the outline panel, as a SwingOutline panel.Returns the page counter, as a JTextField.getPageGrouping(int pageNumber) Returns the page grouping, as a PdfGrouping object for the page to access text content.Returns the PDF decoder used by the Viewer.org.jpedal.examples.viewer.gui.swing.SearchListReturns the search results from a search performing in the Viewer.org.jpedal.examples.viewer.gui.SwingGUIopen the file passed in by user on startup (do not call directly) USED by our testsorg.jpedal.examples.viewer.gui.swing.SwingThumbnailPanelReturns the thumbnail panel.getViewerValue(ViewerValues value) Query the Viewer for the values it holds.voidhandleArguments(String[] args) Have the viewer handle program argumentsvoidloadProperties(String props) Should be called before setupViewervoidloadProperties(Map<String, String> props) Should be called before setupViewerstatic voidmain method to run the software as standalone applicationvoidopenDefaultFile(String defaultFile) voidsetRootContainer(Object rootContainer) Sets the Swing container to add the Viewer to, such as a JFrame's content pane.voidinitialise and run client (default as Application in own Frame)
-
Field Details
-
exitOnClose
public static boolean exitOnCloseWhether theViewerCommands.EXITcommand exits the JVM after closing the Viewer. Default is true. This is a static field, so it applies to every Viewer in the JVM.
-
-
Constructor Details
-
Viewer
public Viewer()setup and run client -
Viewer
setup and run client passing in parameter that points to the preferences file we should use. preferences file- Parameters:
rootContainer- Is a swing component that the viewer is displayed insidepreferencesPath- The path of the preferences file
-
Viewer
setup and run client passing in paramter that points to the preferences file we should use.- Parameters:
prefs- Full path to xml file containing preferences
-
-
Method Details
-
getSearchResults
public org.jpedal.examples.viewer.gui.swing.SearchList getSearchResults()Returns 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.- Returns:
- the search results from a search performing in the Viewer
-
main
main method to run the software as standalone application- Parameters:
args- Program arguments passed into the Viewer.
-
debug
run the viewer in debug mode- Parameters:
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- Returns:
- the current gui
-
openDefaultFile
- Parameters:
defaultFile- Allow user to open PDF file to display
-
getPdfDecoder
Returns the PDF decoder used by the Viewer.- Returns:
- the Viewer's PdfDecoderInt
-
setRootContainer
Sets the Swing container to add the Viewer to, such as a JFrame's content pane.The object must be a
java.awt.Container. Null andJSplitPaneare rejected with a RuntimeException; for a split pane, pass one of its components instead.- Parameters:
rootContainer- the container to add the Viewer to
-
loadProperties
Should be called before setupViewer- Parameters:
props- path to the properties file to load
-
loadProperties
Should be called before setupViewer- Parameters:
props- path to the properties file to load
-
setupViewer
public void setupViewer()initialise and run client (default as Application in own Frame) -
handleArguments
Have the viewer handle program arguments- Parameters:
args- :: Program arguments passed into the Viewer.
-
executeCommand
Execute Jpedal functionality from outside the library using this method.EXAMPLES
command = Command.OPENFILE, args = {"/PDFData/Hand_Test/crbtrader.pdf}"
command = Command.OPENFILE, args = {byte[] = {0,1,1,0,1,1,1,0,0,1}, "/PDFData/Hand_Test/crbtrader.pdf}"
command = Command.ROTATION, args = {"90"}
command = Command.OPENURL, args = {"http://www.cs.bham.ac.uk/~axj/pub/papers/handy1.pdf"}for full details see https://www.idrsolutions.com/docs/jpedal/tutorials/viewer/access-pdf-viewer-features-from-your-code
- Parameters:
command- :: enum value from ViewerCommands to specify which command is wantedargs- :: arguments for the desired command- Returns:
- any returned value from executed command
-
getViewerValue
Query the Viewer for the values it holds.- Parameters:
value- :: enum value from ViewerValues to specify which value is wanted- Returns:
- any returned value or null
-
getOutlinePanel
Returns the outline panel, as a SwingOutline panel.- Returns:
- the outline panel, as a SwingOutline panel
-
getThumbnailPanel
public org.jpedal.examples.viewer.gui.swing.SwingThumbnailPanel getThumbnailPanel()Returns the thumbnail panel.- Returns:
- the thumbnail panel
-
getPageGrouping
Returns the page grouping, as a PdfGrouping object for the page to access text content.- Parameters:
pageNumber- the page number- Returns:
- the page grouping, as a PdfGrouping object for the page to access text content
-
getPageCounter
Returns the page counter, as a JTextField.- Returns:
- the page counter, as a JTextField
-
addExternalHandler
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 https://www.idrsolutions.com/docs/jpedal/api-documents/custom-interfaces- Parameters:
newHandler- Implementation of interface provided by IDR solutionstype- 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
-