Examples of XWPFDocument


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

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

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

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

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

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

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

        assertTrue(extractor.getText().contains("pendant worn"));
        assertTrue(extractor.getText().contains("extremely well"));
    }
View Full Code Here

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

        assertTrue(extractor.getText().contains("pendant worn"));
        assertTrue(extractor.getText().contains("extremely well"));
    }

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

        assertTrue(extractor.getText().contains("Section 1"));
        assertTrue(extractor.getText().contains("Section 2"));
        assertTrue(extractor.getText().contains("Section 3"));
View Full Code Here

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

    /**
     * Test that we can open and process .docm
     *  (macro enabled) docx files (bug #45690)
     */
    public void testDOCMFiles() {
        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("45690.docm");
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

        assertTrue(extractor.getText().contains("2004"));
        assertTrue(extractor.getText().contains("2008"));
        assertTrue(extractor.getText().contains("(120 "));
View Full Code Here

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

         if (is.available() == 0)
         {
            return "";
         }
        
         XWPFDocument doc;
         try
         {
            doc = SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<XWPFDocument>()
            {
               public XWPFDocument run() throws Exception
               {
                  return new XWPFDocument(is);
               }
            });
         }
         catch (IOException e)
         {
View Full Code Here

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

      reader.readDCProperties(SecurityHelper
         .doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<XWPFDocument>()
         {
            public XWPFDocument run() throws Exception
            {
               return new XWPFDocument(is);
            }
         }));

      return reader.getProperties();
   }
View Full Code Here

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

     * @see org.apache.poi.xwpf.extractor.XWPFWordExtractor#getText()
     */
    @Override
    protected void buildXHTML(XHTMLContentHandler xhtml)
            throws SAXException, XmlException, IOException {
        XWPFDocument document = (XWPFDocument) extractor.getDocument();
        XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();

        // headers
        extractHeaders(xhtml, hfPolicy);

        // first all paragraphs
        Iterator<XWPFParagraph> i = document.getParagraphsIterator();
        while (i.hasNext()) {
            XWPFParagraph paragraph = i.next();

            CTSectPr ctSectPr = null;
            if (paragraph.getCTP().getPPr() != null) {
View Full Code Here

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

*/
public class XWPFTestDataSamples {

    public static XWPFDocument openSampleDocument(String sampleName) throws IOException {
        InputStream is = POIDataSamples.getDocumentInstance().openResourceAsStream(sampleName);
        return new XWPFDocument(is);
    }
View Full Code Here

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

    public static XWPFDocument writeOutAndReadBack(XWPFDocument doc) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
        doc.write(baos);
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        return new XWPFDocument(bais);
    }
View Full Code Here

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

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

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.