Package org.apache.poi.xwpf.usermodel

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


      assertEquals(true, doc.isEnforcedReadonlyProtection());
      assertEquals(false, doc.isEnforcedTrackedChangesProtection());
  }
 
  public void testGIFSupport() throws Exception {
      XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("WithGIF.docx");
      ArrayList<PackagePart> gifParts = doc.getPackage().getPartsByContentType(XWPFRelation.IMAGE_GIF.getContentType());
      assertEquals("Expected exactly one GIF part in package.",1,gifParts.size());
      PackagePart gifPart = gifParts.get(0);
     
      List<POIXMLDocumentPart> relations = doc.getRelations();
      POIXMLDocumentPart gifDocPart = null;
      for (POIXMLDocumentPart docPart : relations)
        {
            if (gifPart == docPart.getPackagePart())
            {
View Full Code Here


    @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);
View Full Code Here

  public void testWord() throws Exception {
    File f = new File(dirname, "WordWithAttachments.docx");
    assertTrue(f.exists());
   
    POIXMLDocument doc = new XWPFDocument(OPCPackage.open(f.toString()));
    test(doc, 5);
  }
View Full Code Here

  public void testOpen() throws Exception {
    POIXMLDocument.openPackage(sampleFile.toString());
    POIXMLDocument.openPackage(complexFile.toString());
   
    new XWPFDocument(
        POIXMLDocument.openPackage(sampleFile.toString())
    );
    new XWPFDocument(
        POIXMLDocument.openPackage(complexFile.toString())
    );
   
    XWPFDocument xml;
   
    // Simple file
    xml = new XWPFDocument(
        POIXMLDocument.openPackage(sampleFile.toString())
    );
    // Check it has key parts
    assertNotNull(xml.getDocument());
    assertNotNull(xml.getDocument().getBody());
    assertNotNull(xml.getStyle());
   
    // Complex file
    xml = new XWPFDocument(
        POIXMLDocument.openPackage(complexFile.toString())
    );
    assertNotNull(xml.getDocument());
    assertNotNull(xml.getDocument().getBody());
    assertNotNull(xml.getStyle());
  }
View Full Code Here

    assertNotNull(xml.getDocument().getBody());
    assertNotNull(xml.getStyle());
  }
 
  public void testMetadataBasics() throws Exception {
    XWPFDocument xml = new XWPFDocument(
        POIXMLDocument.openPackage(sampleFile.toString())
    );
    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

    assertEquals(null, xml.getProperties().getCoreProperties().getTitle());
    assertEquals(null, xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
  }
 
  public void testMetadataComplex() throws Exception {
    XWPFDocument xml = new XWPFDocument(
        POIXMLDocument.openPackage(complexFile.toString())
    );
    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

public class XWPFWordExtractor extends POIXMLTextExtractor {
  private XWPFDocument document;
  private boolean fetchHyperlinks = false;
 
  public XWPFWordExtractor(OPCPackage container) throws XmlException, OpenXML4JException, IOException {
    this(new XWPFDocument(container));
  }
View Full Code Here

         if (is.available() == 0)
         {
            return "";
         }
        
         XWPFDocument doc;
         try
         {
            doc = new XWPFDocument(is);
         }
         catch (IOException e)
         {
            throw new DocumentReadException("Can't open message.", e);
         }
View Full Code Here

    * @see org.exoplatform.services.document.DocumentReader#getProperties(java.io.InputStream)
    */
   public Properties getProperties(InputStream is) throws IOException, DocumentReadException
   {
      POIPropertiesReader reader = new POIPropertiesReader();
      reader.readDCProperties(new XWPFDocument(is));
      return reader.getProperties();
   }
View Full Code Here

public final class TestPOIXMLProperties extends TestCase {
  private POIXMLProperties _props;
  private CoreProperties _coreProperties;

  public void setUp() {
    XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("documentProperties.docx");
    _props = sampleDoc.getProperties();
    _coreProperties = _props.getCoreProperties();
    assertNotNull(_props);
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.xwpf.usermodel.XWPFDocument

Copyright © 2018 www.massapicom. 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.