use of org.apache.poi.hwpf.converter.WordToTextConverter in project poi by apache.
the class WordExtractor method getText.
/**
* Grab the text, based on the WordToTextConverter. Shouldn't include any
* crud, but slower than getTextFromPieces().
*/
public String getText() {
try {
WordToTextConverter wordToTextConverter = new WordToTextConverter();
HeaderStories hs = new HeaderStories(doc);
if (hs.getFirstHeaderSubrange() != null)
wordToTextConverter.processDocumentPart(doc, hs.getFirstHeaderSubrange());
if (hs.getEvenHeaderSubrange() != null)
wordToTextConverter.processDocumentPart(doc, hs.getEvenHeaderSubrange());
if (hs.getOddHeaderSubrange() != null)
wordToTextConverter.processDocumentPart(doc, hs.getOddHeaderSubrange());
wordToTextConverter.processDocument(doc);
wordToTextConverter.processDocumentPart(doc, doc.getMainTextboxRange());
if (hs.getFirstFooterSubrange() != null)
wordToTextConverter.processDocumentPart(doc, hs.getFirstFooterSubrange());
if (hs.getEvenFooterSubrange() != null)
wordToTextConverter.processDocumentPart(doc, hs.getEvenFooterSubrange());
if (hs.getOddFooterSubrange() != null)
wordToTextConverter.processDocumentPart(doc, hs.getOddFooterSubrange());
return wordToTextConverter.getText();
} catch (RuntimeException e) {
throw e;
} catch (Exception exc) {
throw new RuntimeException(exc);
}
}
use of org.apache.poi.hwpf.converter.WordToTextConverter in project poi by apache.
the class Word6Extractor method getText.
public String getText() {
try {
WordToTextConverter wordToTextConverter = new WordToTextConverter();
wordToTextConverter.processDocument(doc);
return wordToTextConverter.getText();
} catch (Exception exc) {
// fall-back
StringBuffer text = new StringBuffer();
for (String t : getParagraphText()) {
text.append(t);
}
return text.toString();
}
}
Aggregations