use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestXWPFWordExtractor method testFormFootnotes.
public void testFormFootnotes() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("form_footnotes.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
String text = extractor.getText();
assertContains(text, "testdoc");
assertContains(text, "test phrase");
extractor.close();
}
use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestXWPFWordExtractor method testNoFieldCodes.
/**
* The output should not contain field codes, e.g. those specified in the
* w:instrText tag (spec sec. 17.16.23)
*
* @throws IOException
*/
public void testNoFieldCodes() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("FieldCodes.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
String text = extractor.getText();
assertTrue(text.length() > 0);
assertFalse(text.contains("AUTHOR"));
assertFalse(text.contains("CREATEDATE"));
extractor.close();
}
use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestXWPFWordExtractor method testGetSimpleText.
/**
* Get text out of the simple file
*
* @throws IOException
*/
public void testGetSimpleText() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
String text = extractor.getText();
assertTrue(text.length() > 0);
// Check contents
assertStartsWith(text, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc at risus vel erat tempus posuere. Aenean non ante. Suspendisse vehicula dolor sit amet odio.");
assertEndsWith(text, "Phasellus ultricies mi nec leo. Sed tempus. In sit amet lorem at velit faucibus vestibulum.\n");
// Check number of paragraphs by counting number of newlines
int numberOfParagraphs = StringUtil.countMatches(text, '\n');
assertEquals(3, numberOfParagraphs);
extractor.close();
}
use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestXWPFWordExtractor method testTableFootnotes.
public void testTableFootnotes() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("table_footnotes.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
assertContains(extractor.getText(), "snoska");
extractor.close();
}
use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestXWPFWordExtractor method testDrawings.
/**
* Test for parsing document with drawings to prevent
* NoClassDefFoundError for CTAnchor in XWPFRun
*/
public void testDrawings() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("drawing.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
String text = extractor.getText();
assertTrue(text.length() > 0);
extractor.close();
}
Aggregations