PDF Command Line Tools Tutorial
This tutorial aims to introduce you to using JPedal from the command line. The command line tools give access to a host of features such as silent print and text extraction as well as the ability to invoke GUI tools such as the content extractor.
NB: If you're using the demo version of JPedal then remember to change jpedal.jar to jpedal_trial.jar (or whatever you've called it) when following this tutorial.
Basics - create some variables
To make life easier it might be worth setting a temporary variable to point at the directory holding your copy of the jpedal.jar.
| Windows: | set jpedalDir =path-containing-jpedal.jar |
| MacOS X Linux: | jpedalDir=path-containing-jpedal.jar |
Basics - running Java programs
There is a special keyword java which allows you to run any java program. You type in java along with details of the program you want to run and any additional values.
For running the simple viewer, for example, its just:
| Windows: | java -jar %jpedalDir%\jpedal.jar |
| MacOS X Linux: | java -jar $jpedalDir/jpedal.jar |
Basics - passing parameters
Several examples allow you to pass in values (ie name of file or printer). If any of your values contain spaces (C:/Program Files/my pdf file.pdf) then you need to include it inside quotes or else it will not be read correctly ("C:/Program Files/my pdf file.pdf").
To pass arguments to JPedal, such as what PDF to open in the viewer:
| Windows: | java -jar %jpedalDir%\jpedal.jar mypdf.pdf |
| MacOS X Linux: | java -jar $jpedalDir/jpedal.jar mypdf.pdf |
-jar allows you to run the defined default class - this is SimpleViewer for JPedal. So you cannot use it to run any example (you need to look at the classpath section below).
Basics - Built in Java options
Java includes lots of its own parameters to allow you to fine tune how Java works. There is a full list here.
You might also want to increase the amount of memory that the JVM has to run JPedal using the -Xmx and -Xms flags (maximum and start heap size respectively).
| Windows: | java -Xms256m -Xmx256m -jar %jpedalDir%\jpedal.jar dirtyGreatPDF.pdf |
| MacOS X Linux: | java -Xms256m -Xmx256m -jar $jpedalDir/jpedal.jar dirtyGreatPDF.pdf |
Classpath
In order to invoke different functions of JPedal from the command line you have to use the -classpath or -cp flag to tell the JVM where to call the main method from. For example:
| Windows: | java -cp %jpedalDir%\jpedal.jar org/jpedal/examples/PageCount example.pdf |
| MacOS X Linux: | java -cp $jpedalDir/jpedal.jar org/jpedal/examples/PageCount example.pdf |
The console will display the amount of pages in the example.pdf.
Commandline Tutorials
Below is a list of other JPedal features that can be accessed through the command line:
PDF Clipped Image Extraction
Java PDF to image conversion
High resolution PDF to image conversion
Silent printing
Extract PDF Form Data
Extract Images from PDF files
PDF Clipped Image Extraction
Extract PDF text from Structured Content in PDF files
PDF to text conversion
Extract Text In Rectangle from PDF files - output in table
PDF to text as a Word List
Extract PDF Outline
PDF Search in a file
PDF Page Count
Show properties of a PDF file
Show PDF fonts used in a PDF file
JVM options for full details of JVM settings which can enable JAI and compress Tiffs
Additional optional libraries lists items which may be needed for some PDF files or functionality.
Feedback, questions and updates
There is a support forum for questions, or you can contact IDRsolutions via our contact page.
There is an RSS feed with regular updates about our products. We recommend you subscribe so we can keep you updated.
Please let us know if you find any bugs with the bug report form.




