事前定義された基準に基づいて、docx ドキュメントを複数のドキュメントに分割しようとしています。以下は、段落に分割するための私のアプローチです
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);
FileOutputStream outputStream = new FileOutputStream(fullPath);
outputDocument.write(outputStream);
outputDocument.close();
doc.close();
}
} catch (IOException e) {
e.printStackTrace();
}
上記のコードで段落を抽出することはできますが、ページを抽出する方法が見つかりません。私の理解では、Word のページはレンダリングの問題であり、Word アプリケーションのランタイムで発生します。