Can I use PDFBox within Eclipse?
I am using Eclipse Luna Service Release 2 (4.4.2) and Java on a MacBook Pro running OS X Yosemite 10.10. My Java program reads .txt files and searches via regular expressions for certain strings, outputs them in various formats to a database and/or a file. This works well with original Word files (converted to .txt), but not PDF files. The input files have many Unicode characters (e.g., a̐ ā̆ I ī u ū ṛ ṙ ṝ r̄̆ ḷ e o b y v r l m ṁ ṃ m̐ ñ ṅ n ṇ n j h g ḍ d k p c ṭ t ś ṣ ḥ ).
I have tried using some simple routines within the Eclipse framework, but the reading of an input file constantly fails every time that I try. I suspect that PDFBox and Eclipse have different I/O conventions.
The following simple model program does not work within Eclipse. I have tried various ways of getting it to load the file.
import java.io.File;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
public class LoadingExistingDocument {
public static void main(String args[]) throws IOException {
//Loading an existing document
File file = new File("C:/PdfBox_Examples/sample.pdf");
PDDocument document = PDDocument.load(file);
System.out.println("PDF loaded");
//Adding a blank page to the document
document.addPage(new PDPage());
//Saving the document
document.save("C:/PdfBox_Examples/sample.pdf");
//Closing the document
document.close();
}
}
Do I need to put PDFBox inside Eclipse as a plugin?
Some advice on using PDFBox within Eclipse would be greatly appreciated.