use of org.apache.poi.hwpf.usermodel.Paragraph in project tika by apache.
the class WordExtractor method handleHeaderFooter.
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);
}
}
}
xhtml.endElement("div");
}
}
use of org.apache.poi.hwpf.usermodel.Paragraph in project poi by apache.
the class QuickTest method main.
public static void main(String[] args) throws IOException {
HWPFDocument doc = new HWPFDocument(new FileInputStream(args[0]));
Range r = doc.getRange();
System.out.println("Example you supplied:");
System.out.println("---------------------");
for (int x = 0; x < r.numSections(); x++) {
Section s = r.getSection(x);
for (int y = 0; y < s.numParagraphs(); y++) {
Paragraph p = s.getParagraph(y);
for (int z = 0; z < p.numCharacterRuns(); z++) {
// character run
CharacterRun run = p.getCharacterRun(z);
// character run text
String text = run.text();
// show us the text
System.out.print(text);
}
// use a new line at the paragraph break
System.out.println();
}
}
doc.close();
}
use of org.apache.poi.hwpf.usermodel.Paragraph in project poi by apache.
the class TestSprms method testInnerTable.
private void testInnerTable(HWPFDocument hwpfDocument) {
Range range = hwpfDocument.getRange();
for (int p = 0; p < range.numParagraphs(); p++) {
Paragraph paragraph = range.getParagraph(p);
char first = paragraph.text().toLowerCase(Locale.ROOT).charAt(0);
if ('1' <= first && first < '4') {
assertTrue(paragraph.isInTable());
assertEquals(2, paragraph.getTableLevel());
}
if ('a' <= first && first < 'z') {
assertTrue(paragraph.isInTable());
assertEquals(1, paragraph.getTableLevel());
}
}
}
use of org.apache.poi.hwpf.usermodel.Paragraph in project poi by apache.
the class HWPFLister method dumpParagraphsDom.
public void dumpParagraphsDom(boolean withText) {
Range range = _doc.getOverallRange();
for (int p = 0; p < range.numParagraphs(); p++) {
Paragraph paragraph = range.getParagraph(p);
System.out.println(p + ":\t" + paragraph);
if (withText)
System.out.println(paragraph.text());
}
}
use of org.apache.poi.hwpf.usermodel.Paragraph in project poi by apache.
the class WordExtractor method getParagraphText.
protected static String[] getParagraphText(Range r) {
String[] ret;
ret = new String[r.numParagraphs()];
for (int i = 0; i < ret.length; i++) {
Paragraph p = r.getParagraph(i);
ret[i] = p.text();
// Fix the line ending
if (ret[i].endsWith("\r")) {
ret[i] = ret[i] + "\n";
}
}
return ret;
}
Aggregations