With a PDFBox, you can open the original PDF file in a PDDocument, and then use getDocumentCatalog (). getAllPages () to get a list of pages. Reorder the list in the order you want and write each page in new documents.
PDDocument newDoc = new PDDocument(); PDDocument oldDoc = PDDocument.load (args[0]); List allPages = oldDoc.getDocumentCatalog().getAllPages();
source share