问题
I have code to get paragraphs from a .doc file in Apache POI, but I'd like to get footnotes also. Also, is this the only way to get paragraphs?
Code so far:
InputStream stream = ...
HWPFDocument document = new HWPFDocument(stream);
Range range = document.getRange();
StyleSheet stylesheet = document.getStyleSheet();
for (int i = 0; i < range.numParagraphs(); i++) {
Paragraph paragraph = range.getParagraph(i);
String text = paragraph.text();
}
Any ideas?
回答1:
You could try this...
WordExtractor extractor = new WordExtractor(document);
paragraphs.addAll(Arrays.asList(extractor.getParagraphText()) );
footnotes.addAll(Arrays.asList(extractor.getFootnoteText()) );
extractor.close();
来源:https://stackoverflow.com/questions/36392563/how-can-i-get-footnotes-and-paragraphs-from-apache-poi