We’ve added a new API to our PDF viewing component for back and forth navigation (go to previous and next view). It will be released in jPDFViewer, jPDFNotes, jPDFEditor 2013R2 release scheduled for August 2013. The com.qoppa.pdfViewer.history package contains the classes that provide access to the “browsing history” of a document. This sample for navigating within a single document is provided in SimpleDocumentHistory (below). When a document is loaded in PDFViewerBean, a newLocationHistory is created and maintains a list of Location’s that have been viewed/visited. Adding “Next” and “Prev” buttons to thePDFViewerBean can be accomplished using these classes along with a HistoryListener that is added to PDFViewerBean. WhenHistoryListener.locationChanged() is called, the Next/Prev buttons can be updated accordingly.

PDFViewerBean only maintains location history information for a single document. A containing application can provide document history across multiple documents by using the getLocationHistory and setLocationHistory methods to get and set existing histories when navigating across documents. This sample is provided in MultipleDocumentHistory (below). In order to implement this, you need to save eachLocationHistory with its associated document. When a new document is loaded, a new LocationHistory object is created.PDFViewerBean calls HistoryListener.previousDocument() when a request has been made to go to the previous location, but there are no previous Locations in the LocationHistory of the current document. In the MultipleDocumentHistory sample, the previous document is then loaded, and its associated LocationHistory is set in PDFViewerBean. Similar logic is used for the next document. MultipleDocumentHistory uses a flag to determine if it is loading a new document or loading a document from its history list.

When loading a new document and saving its LocationHistory for later use, we do not recommend using a reference to either PDFDocument or PDFSource as this will cause every document in the history list to be saved in memory. MultipleDocumentHistory uses the file path in order to reload the document from the history list, you can modify this to use URLs.