Please choose a menu option

RSS feed? News:

19 Aug 10 Version 4.36 build 60 released JPedal can now read PDF's aloud using the Freetts library, improvements to signing and mouse functions, enhancements to Font and Javascript engines. More Info...

29 Jul 10 JPedal Java ME Viewer Now released and available under an LGPL licence More Info...

12 Jul 10 Version 4.30 build 16 released Enhanced Print dialog, Control via Javascript and Applet enhancements Read More ...

10 Jun 10 Version 4.21 build 56 released Major speed improvements to viewer and general parsing speed. Read More ...

10 Jun 10 JBig 2 image decoder Version 2 released Major Upgrade to JBig2 image decoder - 3-5 times faster. Read More ...

03 Jun 10 Version 4.20 build 21 released Major Upgrade to TrueType font engine supporting Chinese fonts, speed improvements. Read More ...

22 Apr 10 EBook reader encryption Pjes now handles encrypted PDFs - upload an Encrypted PDF, and everyone will need the password to open it.
Ebook reader...

19 Mar 10 Version 4.10 build 16 released First implementation of JPedal in JavaME, support for linearization of PDFs, Coons and Tensor shading support.Read More ...

04 Feb 10 Major new version New look, new page turning mode, enhanced search, code tidy up and much more...

23 Sep 09 PDF Java Ebook Solution IDRsolutions is pleased to announce a new free service which embeds PDFs inside our viewer. A must for e-book authors and distributors. Read More ...

Access Java PDF Viewer Functions

Once you have integrated a PDF Viewer component, you may want to access its functions from your own java code. This section explains how to do this.

Sample Java code

Click here for example Java code.


How to interact with the Java PDF viewer

To interact with the Java PDF viewer is simple and it can all be handled through one method.

Object simpleViewer.executeCommand(int, object[]) - Click here to view this method.

This method uses an int to specify what you wish to do and the object[] specifies input arguments where certain methods require it for full customisation, otherwise the method will use the standard jpedal code. The returned Object returns anything that may be returned from the given command. Unless otherwise stated this value will be null. This will be useful if you wish to use your own popup windows for loading pdfs, printing etc.

The int values to specify a command to be used can be found in Commands.java.

The following methods will accept an object[] input.

Commands.OPENFILE :: input = {"/PDFData/example.pdf"}
Input should be the full PDF filename expressed as a string

Commands.OPENFILE :: input = {new File("/PDFData/example.pdf")}
Input should be a PDF File object

Commands.OPENFILE :: input = {new FileInputStream("/PDFData/example.pdf")}
Input should be an InputStream containing data for a PDF file.

Commands.OPENFILE :: input = {data, "/PDFData/example.pdf"}
Input should be a byte array of the pdf data you wish to load and the PDF filename expressed as a string

Commands.FORWARDPAGE :: input = {"3"}
Input should be the amount of PDF pages to move by expressed as a string

Commands.BACKPAGE :: input = {"3"}
Input should be the amount of PDF pages to move by expressed as a string

Commands.ROTATION :: input = {"90"}
Input should be the PDF page rotation expressed as 0, 90, 180 or 270 expressed as a string

Commands.OPENURL :: input = {"http://www.cs.bham.ac.uk/~axj/pub/papers/handy1.pdf"}
Input should be the full url of the PDF file location including "http://" at the start expressed as a string

Commands.SCALING :: input = {"300"}
Input should be the PDF scaling value expressed as a string

Commands.SCROLL:: input = {new Rectangle(1,1,100,100), 1}
Input should be, as above, in the following order.
A Rectangle to scroll to on a PDF page.
An Integer value for the PDF page the area is on. If this value is less than 1, greater than the page count or the value is null then current PDF page is assumed.

Commands.FIND :: input = {"example", 0, true, false}
Input should be, as above, in the following order.
String representing the term or terms to be searched for.
Integer value representing a bitwise OR of the static values stored in the class SearchType representing search options.
Boolean value, if true, will treat search value as a list seperated by a space between each value else will treat the entire string as a single PDF search term.
Boolean value, if true, will only search the current page else the entire PDF document is searched.

Commands.PREVIOUSRESULT :: input = null
The input for this command should be a null array. This method will return one of four values.
null = Nothing of note to mention.
Commands.FIRST_DOCUMENT_SEARCH_RESULT_NOW_SHOWN = Integer of value 1 returned when we reach the first search value.
Commands.SEARCH_RETURNED_TO_START = Integer of value 2 returned when we loop between the start and end of the result list.
Commands.SEARCH_NOT_FOUND = Integer of value 3 returned if there are no search results found in this document.

Commands.NEXTRESULT :: input = null
The input for this command should be a null array. This method will return one of four values.
null = Nothing of note to mention.
Commands.FIRST_DOCUMENT_SEARCH_RESULT_NOW_SHOWN = Integer of value 1 returned when we reach the first search value.
Commands.SEARCH_RETURNED_TO_START = Integer of value 2 returned when we loop between the start and end of the result list.
Commands.SEARCH_NOT_FOUND = Integer of value 3 returned if there are no search results found in this document.

 

 

Return to main PDF support section

Click here for the main PDF support area with lots of java examples, PDF tutorials and useful information to get the most out of the JPedal PDF library

 


PDF viewer