Apache POI - Split Word document (docx) to pages
I have been trying to segment a docx document to multiple documents based on a predefined criteria. following is my approach to cut it to paragraphs try { FileInputStream in = new FileInputStream(file); XWPFDocument doc = new XWPFDocument(in); List<XWPFParagraph> paragraphs = doc.getParagraphs(); for (int idx = 0; idx < paragraphs.size(); idx++) { XWPFDocument outputDocument = new XWPFDocument(); createParagraphInAnotherDocument(outputDocument, paragraphs.get(idx).getText()); String fullPath = String.format("./content/output/%1$s_%2$s_%3$04d.docx", FileUtils.getFileName(file), getName(), idx);