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);