Hi there Please can someone help me with this simple problem I believe... I've already asked over 8 experts on a java chat website yet no-one can seem to help me :(. I have downloaded the jar files from http://pdfbox.apache.org/download.html. I have opened blueJ IDE and loaded the jars. When I type in
import org.apache.pdfbox.*;
import org.apache.pdfbox.pdmodel;
import org.apache.pdfbox.pdmodel.PDPage;
I get an error message:
error has occured cannot find org.apache.pdfbox
I have tried netbeans also and gone to project properties and added the jar, I've also gone to the side menu on netbeans and tried that way. I still get the same error. Can someone please help? I've tried this on 3 different pc's.
okay guys to give me more info. I downloaded the jars and put them in a folder in blueJ i went to options and selected the jar files they say 'loaded'. I also did the same in Netbeans, I've shown the IDE where the Jars are it still does not work here is the full code, its just a sample code taken from the PDFBOX website I am trying.
import org.apache.pdfbox.exceptions.*;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
/**
* This will create a blank PDF and write the contents to a file.
*/
public class CreateBlankPDF
{
/**
* This will create a blank PDF and write the contents to a file.
*
* @param file The name of the file to write to.
*
* @throws IOException If there is an error writing the data.
* @throws COSVisitorException If there is an error while generating the document.
*/
public void create( String file ) throws IOException, COSVisitorException
{
PDDocument document = null;
try
{
document = new PDDocument();
//Every document requires at least one page, so we will add one
//blank page.
PDPage blankPage = new PDPage();
document.addPage( blankPage );
document.save( file );
}
finally
{
if( document != null )
{
document.close();
}
}
}
/**
* This will create a blank document.
*
* @param args The command line arguments.
*
* @throws IOException If there is an error writing the document data.
* @throws COSVisitorException If there is an error generating the data.
*/
public static void main( String[] args ) throws IOException, COSVisitorException
{
if( args.length != 1 )
{
usage();
}
else
{
CreateBlankPDF creator = new CreateBlankPDF();
creator.create( args[0] );
}
}
/**
* This will print the usage of this class.
*/
private static void usage()
{
System.err.println( "usage: java org.apache.pdfbox.examples.pdmodel.CreateBlankPDF <outputfile.pdf>" );
}
}
This is sorted. I was downloading the JAR file wrong. I checked the file size and noticed it was only 20kb when it was meant to be over 9mb. Thank you to everyone !