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?
解决方案
You could try this...
WordExtractor extractor = new WordExtractor(document);
paragraphs.addAll(Arrays.asList(extractor.getParagraphText()) );
footnotes.addAll(Arrays.asList(extractor.getFootnoteText()) );
extractor.close();