Examples of XWPFDocument


Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    assertNotNull(xml.getDocument().getBody());
    assertNotNull(xml.getStyle());
  }

  public void testMetadataBasics() {
    XWPFDocument xml = XWPFTestDataSamples.openSampleDocument("sample.docx");
    assertNotNull(xml.getProperties().getCoreProperties());
    assertNotNull(xml.getProperties().getExtendedProperties());

    assertEquals("Microsoft Office Word", xml.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
    assertEquals(1315, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getCharacters());
    assertEquals(10, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getLines());

    assertEquals(null, xml.getProperties().getCoreProperties().getTitle());
    assertEquals(null, xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    assertEquals(null, xml.getProperties().getCoreProperties().getTitle());
    assertEquals(null, xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
  }

  public void testMetadataComplex() {
    XWPFDocument xml = XWPFTestDataSamples.openSampleDocument("IllustrativeCases.docx");
    assertNotNull(xml.getProperties().getCoreProperties());
    assertNotNull(xml.getProperties().getExtendedProperties());

    assertEquals("Microsoft Office Outlook", xml.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
    assertEquals(5184, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getCharacters());
    assertEquals(0, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getLines());

    assertEquals(" ", xml.getProperties().getCoreProperties().getTitle());
    assertEquals(" ", xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    assertEquals(" ", xml.getProperties().getCoreProperties().getTitle());
    assertEquals(" ", xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
  }

  public void testWorkbookProperties() {
    XWPFDocument doc = new XWPFDocument();
    POIXMLProperties props = doc.getProperties();
    assertNotNull(props);
    assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    /**
     * Get text out of the simple file
     */
    public void testGetSimpleText() {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

        String text = extractor.getText();
        assertTrue(text.length() > 0);

View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

    /**
     * Tests getting the text out of a complex file
     */
    public void testGetComplexText() {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("IllustrativeCases.docx");
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

        String text = extractor.getText();
        assertTrue(text.length() > 0);

View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

        }
        assertEquals(103, ps);
    }

    public void testGetWithHyperlinks() {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("TestDocument.docx");
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

        // Now check contents
        // TODO - fix once correctly handling contents
        extractor.setFetchHyperlinks(false);
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

                extractor.getText()
        );
    }

    public void testHeadersFooters() {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("ThreeColHeadFoot.docx");
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

        assertEquals(
                "First header column!\tMid header\tRight header!\n" +
                        "This is a sample word document. It has two pages. It has a three column heading, and a three column footer\n" +
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

                extractor.getText()
        );
    }

    public void testFootnotes() {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("footnotes.docx");
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

        assertTrue(extractor.getText().contains("snoska"));
    }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

        assertTrue(extractor.getText().contains("snoska"));
    }


    public void testTableFootnotes() {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("table_footnotes.docx");
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

        assertTrue(extractor.getText().contains("snoska"));
    }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFDocument

        assertTrue(extractor.getText().contains("snoska"));
    }

    public void testFormFootnotes() {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("form_footnotes.docx");
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

        String text = extractor.getText();
        assertTrue("Unable to find expected word in text\n" + text, text.contains("testdoc"));
        assertTrue("Unable to find expected word in text\n" + text, text.contains("test phrase"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.