Package org.docx4j.openpackaging.parts.WordprocessingML

Examples of org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.addObject()


     
      // Example 4: Here is an easier way:
      String str = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ><w:r><w:rPr><w:b /></w:rPr><w:t>Example 4</w:t></w:r></w:p>";
     
      mdp.addObject(
            org.docx4j.XmlUtils.unmarshalString(str) );

     
      // Example 5: Let's add a table
      int writableWidthTwips = wordMLPackage.getDocumentModel().getSections().get(0).getPageDimensions().getWritableWidthTwips();
View Full Code Here


      int cellWidthTwips = new Double(
                    Math.floor( (writableWidthTwips/cols ))
                      ).intValue();
     
      Tbl tbl = TblFactory.createTable(3, 3, cellWidthTwips);
      mdp.addObject(tbl);
     
   
       // Pretty print the main document part
    System.out.println(
        XmlUtils.marshaltoString(mdp.getJaxbElement(), true, true) );
View Full Code Here

        else {
          org.docx4j.wml.P paraToAdd = handleP(wordMLPackage, doc,
              p, stylesheet, documentPart, factory);

          documentPart.addObject(paraToAdd);
        }

      }
    }
View Full Code Here

     
      // Example 4: Here is an easier way:
      String str = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ><w:r><w:rPr><w:b /></w:rPr><w:t>Example 4</w:t></w:r></w:p>";
     
      mdp.addObject(
            org.docx4j.XmlUtils.unmarshalString(str) );

     
      // Example 5: Let's add a table
      int writableWidthTwips = wordMLPackage.getDocumentModel().getSections().get(0).getPageDimensions().getWritableWidthTwips();
View Full Code Here

      int cellWidthTwips = new Double(
                    Math.floor( (writableWidthTwips/cols ))
                      ).intValue();
     
      Tbl tbl = TblFactory.createTable(3, 3, cellWidthTwips);
      mdp.addObject(tbl);
     
   
       // Pretty print the main document part
    System.out.println(
        XmlUtils.marshaltoString(mdp.getJaxbElement(), true, true) );
View Full Code Here

    // Add it to a paragraph
    org.docx4j.wml.ObjectFactory wmlFactory = Context.getWmlObjectFactory();
    org.docx4j.wml.P paragraph = wmlFactory.createP();
   
    paragraph.getContent().add( subdoc );
    mdp.addObject(paragraph);
   
    // Now save it
    wordMLPackage.save(new java.io.File(System.getProperty("user.dir") + "/OUT_SubDocumentMASTER.docx") );
   
  }
View Full Code Here

    Hyperlink link = createHyperlink(mdp, "http://slashdot.org");
   
    // Add it to a paragraph
    org.docx4j.wml.P paragraph = Context.getWmlObjectFactory().createP();
    paragraph.getContent().add( link );
    mdp.addObject(paragraph);
   
    // Now save it
    wordMLPackage.save(new java.io.File(System.getProperty("user.dir") + "/OUT_HyperlinkTest.docx") );
   
    // Uncomment to display the result as Flat OPC XML
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.