Hi,

----- original Nachricht --------

Betreff: Need your help: How to use pdfbox
Gesendet: Di, 02. Mrz 2010
Von: I I<[email protected]>

> Hello,
> 
> I want to read pdf contents using Java or convert pdf to text using Java. I
> downloaded the pdfbox and unzipped it to a folder. I then executed *ant *on
> command line prompt. Everything was fine with some warnings there. And then
> I used the command as shown below from the folder src/main/java. I used
> this
> command as there is no ExtractText.class file as yet.
The ant build script and the maven pom is only needed if you like to compile 
your own
version of pdfbox. Otherwise you probably would prefer the precompiled version 
which
can be downloaded here [1]


> *C:\pdfbox-1.0.0\src\main\java>javac org\apache\pdfbox\ExtractText.java
> Jan.pdf Jan.txt
"javac" is used to compile some source code but not to execute it. But you 
don't have to do 
that by hand. Maven or ant will do that for you if necessary. See [2] for 
further details


> *C:\pdfbox-1.0.0\src\main\java>java org\apache\pdfbox\ExtractText Jan.pdf
> Jan.pdf
> .....
> 
> *C:\pdfbox-1.0.0\src\main\java>*
> *
> *
> Could you please help me how to extract text from a pdf file. Your help
> will
> be highly appreciated.*
"java" is the correct command to execute a java class, but you didn't use it 
correct.
Try something like this:

java -cp <class search path of directories and zip/jar files> 
org.apache.pdfbox.ExtractText <optional ExtractText parameters>Jan.pdf Jan.pdf

The classpath (-cp)  consists of all jars which can be found in the directory 
"external", the pdfbox.jar itself and the 
resources directory. You can find more information on the optional ExtractText 
parameter at [3]. For further details
on how to use the JVM just try "java -help" or have a look into a suitable 
tutorial, e.g. the Sun java tutorial which
can be found at [4].

BR
Andreas Lehmkühler

[1] http://pdfbox.apache.org/download.html
[2] http://pdfbox.apache.org/userguide/building_pdfbox.html
[3] http://pdfbox.apache.org/commandlineutilities/ExtractText.html
[4] http://java.sun.com/docs/books/tutorial/index.html

Reply via email to