Search in sources :

Example 1 with IBodyElement

use of org.apache.poi.xwpf.usermodel.IBodyElement in project tika by apache.

the class XWPFWordExtractorDecorator method extractIBodyText.

private void extractIBodyText(IBody bodyElement, XWPFListManager listManager, XHTMLContentHandler xhtml) throws SAXException, XmlException, IOException {
    for (IBodyElement element : bodyElement.getBodyElements()) {
        if (element instanceof XWPFParagraph) {
            XWPFParagraph paragraph = (XWPFParagraph) element;
            extractParagraph(paragraph, listManager, xhtml);
        }
        if (element instanceof XWPFTable) {
            XWPFTable table = (XWPFTable) element;
            extractTable(table, listManager, xhtml);
        }
        if (element instanceof XWPFSDT) {
            extractSDT((XWPFSDT) element, xhtml);
        }
    }
}
Also used : XWPFParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph) XWPFTable(org.apache.poi.xwpf.usermodel.XWPFTable) IBodyElement(org.apache.poi.xwpf.usermodel.IBodyElement) XWPFSDT(org.apache.poi.xwpf.usermodel.XWPFSDT)

Example 2 with IBodyElement

use of org.apache.poi.xwpf.usermodel.IBodyElement in project poi by apache.

the class XWPFWordExtractor method getText.

public String getText() {
    StringBuffer text = new StringBuffer();
    XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();
    // Start out with all headers
    extractHeaders(text, hfPolicy);
    // Process all body elements
    for (IBodyElement e : document.getBodyElements()) {
        appendBodyElementText(text, e);
        text.append('\n');
    }
    // Finish up with all the footers
    extractFooters(text, hfPolicy);
    return text.toString();
}
Also used : IBodyElement(org.apache.poi.xwpf.usermodel.IBodyElement) XWPFHeaderFooterPolicy(org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy)

Aggregations

IBodyElement (org.apache.poi.xwpf.usermodel.IBodyElement)2 XWPFHeaderFooterPolicy (org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy)1 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)1 XWPFSDT (org.apache.poi.xwpf.usermodel.XWPFSDT)1 XWPFTable (org.apache.poi.xwpf.usermodel.XWPFTable)1