Hello PDFbox,
I'm Manuel, nice to meet you.
I'm using pdfbox-app-2.0.2.jar api; I would like to slpit a Pdf document, I
have some problems: How I can to set the path file, for to load the file
Pdf for split ?
I think that the problemis here:
document = PDDocument.load(new File("C:\\Users\\Desktop\\EmailTest.pdf"));
because the standard use is:
document = PDDocument.load(new File(filename));
How I can change filename for to set the file path ?
This is my code:
public static void main(String[] args) throws IOException {
PDDocument document;
document = PDDocument.load(new
File("C:\\Users\\Desktop\\EmailTest.pdf"));
Splitter splitter = new Splitter();
List<PDDocument> listOfSplitPages;
listOfSplitPages = splitter.split(document);
Iterator<PDDocument> iterator = listOfSplitPages.listIterator();
// I am using variable i to denote page numbers.
int i = 1;
while(iterator.hasNext()){
PDDocument pd = iterator.next();
// Saving each page with its assumed page no.
pd.save("C:\\Users\\Desktop " + i++ + ".pdf");
}
}
}