Examples of XWPFWordExtractor


Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

    @Override
    public void run() {
        try {
            InputStream isr = new FileInputStream(pathToFile);
            XWPFDocument document = new XWPFDocument(isr);
            XWPFWordExtractor word = new XWPFWordExtractor(document);
            String fileContent = word.getText();

            AddDataToIndex.class.newInstance().doAddData(fileContent,
                    pathToFile, fileName);
            Vars.current_run_indexes--;
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

    PackagePart corePart = pkg.getPart(core.getRelationship(0));
    if(corePart.getContentType().equals(XSSFRelation.WORKBOOK.getContentType())) {
      return new XSSFExcelExtractor(pkg);
    }
    if(corePart.getContentType().equals(XWPFRelation.DOCUMENT.getContentType())) {
      return new XWPFWordExtractor(pkg);
    }
    if(corePart.getContentType().equals(XSLFSlideShow.MAIN_CONTENT_TYPE)) {
      return new XSLFPowerPointExtractor(pkg);
    }
    throw new IllegalArgumentException("No supported documents found in the OOXML package");
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

         catch (OpenXML4JRuntimeException e)
         {
            throw new DocumentReadException("Can't open message.", e);
         }

         XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
         text = extractor.getText();
      }
      finally
      {
         if (is != null)
         {
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

        if(corePart.getContentType().equals(XWPFRelation.DOCUMENT.getContentType()) ||
            corePart.getContentType().equals(XWPFRelation.TEMPLATE.getContentType()) ||
            corePart.getContentType().equals(XWPFRelation.MACRO_DOCUMENT.getContentType()) ||
            corePart.getContentType().equals(XWPFRelation.MACRO_TEMPLATE_DOCUMENT.getContentType()) ) {
      return new XWPFWordExtractor(pkg);
    }

    if(corePart.getContentType().equals(XSLFSlideShow.MAIN_CONTENT_TYPE)) {
      return new XSLFPowerPointExtractor(pkg);
    }
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

         catch (OpenXML4JRuntimeException e)
         {
            throw new DocumentReadException("Can't open message.", e);
         }

         final XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
         text = SecurityHelper.doPrivilegedAction(new PrivilegedAction<String>()
         {
            public String run()
            {
               return extractor.getText();
            }
         });
      }
      finally
      {
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

        // Check we can read the word document in that
        InputStream dataStream = d.getDataStream(filesystem);
        OPCPackage opc = OPCPackage.open(dataStream);
        XWPFDocument doc = new XWPFDocument(opc);
        XWPFWordExtractor ex = new XWPFWordExtractor(doc);
        String text = ex.getText();
        assertNotNull(text);
        assertEquals("This is password protected Word document.", text.trim());
        ex.close();
    }
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

        // Check we can read the word document in that
        InputStream dataStream = d.getDataStream(filesystem);
        OPCPackage opc = OPCPackage.open(dataStream);
        XWPFDocument doc = new XWPFDocument(opc);
        XWPFWordExtractor ex = new XWPFWordExtractor(doc);
        String text = ex.getText();
        assertNotNull(text);
        // I know ... a stupid typo, maybe next time ...
        assertEquals("The is a password protected document.", text.trim());
        ex.close();
    }
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

        // Check we can read the word document in that
        InputStream dataStream = d.getDataStream(filesystem);
        OPCPackage opc = OPCPackage.open(dataStream);
        XWPFDocument doc = new XWPFDocument(opc);
        XWPFWordExtractor ex = new XWPFWordExtractor(doc);
        String text = ex.getText();
        assertNotNull(text);
        // I know ... a stupid typo, maybe next time ...
        assertEquals("The is a password protected document.", text.trim());
        ex.close();
       
        filesystem.close();
    }
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

        // Check we can read the word document in that
        InputStream dataStream = d.getDataStream(filesystem);
        OPCPackage opc = OPCPackage.open(dataStream);
        XWPFDocument doc = new XWPFDocument(opc);
        XWPFWordExtractor ex = new XWPFWordExtractor(doc);
        String text = ex.getText();
        assertNotNull(text);
        assertEquals("This is password protected Word document.", text.trim());
        ex.close();
       
        filesystem.close();
    }
View Full Code Here

Examples of org.apache.poi.xwpf.extractor.XWPFWordExtractor

       }

       // Is it XWPF?
       for(XWPFRelation rel : XWPFWordExtractor.SUPPORTED_TYPES) {
          if(corePart.getContentType().equals(rel.getContentType())) {
             return new XWPFWordExtractor(pkg);
          }
       }

       // Is it XSLF?
       for(XSLFRelation rel : XSLFPowerPointExtractor.SUPPORTED_TYPES) {
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.