Example usage for org.apache.poi.hwpf.model FieldsDocumentPart HEADER

List of usage examples for org.apache.poi.hwpf.model FieldsDocumentPart HEADER

Introduction

In this page you can find the example usage for org.apache.poi.hwpf.model FieldsDocumentPart HEADER.

Prototype

FieldsDocumentPart HEADER

To view the source code for org.apache.poi.hwpf.model FieldsDocumentPart HEADER.

Click Source Link

Document

header subdocument

Usage

From source file:mj.ocraptor.extraction.tika.parser.microsoft.WordExtractor.java

License:Apache License

private void handleHeaderFooter(Range[] ranges, String type, HWPFDocument document, PicturesSource pictures,
        PicturesTable pictureTable, XHTMLContentHandler xhtml) throws SAXException, IOException, TikaException {
    if (countParagraphs(ranges) > 0) {
        xhtml.startElement("div", "class", type);
        for (Range r : ranges) {
            if (r != null) {
                for (int i = 0; i < r.numParagraphs(); i++) {
                    Paragraph p = r.getParagraph(i);

                    String text = p.text();
                    if (text.replaceAll("[\\r\\n\\s]+", "").isEmpty()) {
                        // Skip empty header or footer paragraphs
                    } else {
                        i += handleParagraph(p, 0, r, document, FieldsDocumentPart.HEADER, pictures,
                                pictureTable, xhtml);
                    }//ww w  . jav  a2 s .  c o  m
                }
            }
        }
        xhtml.endElement("div");
    }
}

From source file:org.apache.tika.parser.microsoft.WordExtractor.java

License:Apache License

private void handleHeaderFooter(Range[] ranges, String type, HWPFDocument document, PicturesSource pictures,
        PicturesTable pictureTable, XHTMLContentHandler xhtml) throws SAXException, IOException, TikaException {
    if (countParagraphs(ranges) > 0) {
        xhtml.startElement("div", "class", type);
        ListManager listManager = new ListManager(document);
        for (Range r : ranges) {
            if (r != null) {
                for (int i = 0; i < r.numParagraphs(); i++) {
                    Paragraph p = r.getParagraph(i);

                    i += handleParagraph(p, 0, r, document, FieldsDocumentPart.HEADER, pictures, pictureTable,
                            listManager, xhtml);
                }//ww w. j a  v a  2s . c om
            }
        }
        xhtml.endElement("div");
    }
}