Marco,
With appache pdfbox you can split the document into pages as below:
PDDocument document = PDDocument.load(myPDF);
Splitter splitter = new Splitter();
List<PDDocument> splittedDocuments = splitter.split(document);
You can control the number of pages on every splitted PDF using setSplitAtPage(split)
That is more a stackoverflow question: https://stackoverflow.com/questions/5736675/itext-split-a-pdf-into-several-pdf-1-per-page
Regards,
Ronald
Based on the answer from Ronald I have created the following code which is giving me the first page of a PDF.
InputStream is = Core.getFileDocumentContent(this.getContext(), __PDFDocument);
PdfReader reader = new PdfReader(is);
Document document = new Document(reader.getPageSizeWithRotation(1));
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("hhmmssSSS");
Random rand = new Random();
formatter.format(date);
File file = new File(Core.getConfiguration().getTempPath().toString() + "/" + formatter.format(date) + rand.nextInt(50) + ".pdf");
PdfCopy writer = new PdfCopy(document, new FileOutputStream(file));
document.open();
PdfImportedPage page = writer.getImportedPage(reader, 1);
writer.addPage(page);
document.close();
writer.close();
InputStream IsFile = new FileInputStream(file);
IMendixObject obj = Core.instantiate(this.getContext(), CertificateDocument.getType());
Core.storeFileDocumentContent(this.getContext(), obj, IsFile);
is.close();
IsFile.close();
file.delete();
return obj;
I used Split PDF Software It runs on all Windows versions without any problem. I have separated several pages from a PDF of 250 pages in few minutes using this software.
Visit at more info; https://www.osttopstapp.com/pdf-split.html