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
I've found that the best tool for splitting PDF files is Softaken PDF Splitter Software. This program can be used to split PDF files. The program splits Adobe PDF files based on the number of pages. You can split a PDF file into many files with the Split PDF Tool while preserving the original structure and data. You can split PDFs without having to install Adobe Reader. You can use this tool for personal or professional purposes. All versions of Windows, including Windows 11, 10, 8.1, 8, 7, and all previous editions, are compatible with this software.
Read More:- https://www.softakensoftware.com/pdf-splitter.html