Package org.docx4j.wml

Examples of org.docx4j.wml.P


      // is a better alternative if you are using a new style, since it
      // will ensure that the style is activated 

    // Example 3b: bold text
      // Well, actually you can use addParagraphOfText:
    P p3b = mdp.addParagraphOfText("Example 3b (bold)");
    R r3b = (R)p3b.getContent().get(0);
      // .. now set rPr (I'll just reuse the above object)
    r3b.setRPr(rpr);

     
      // Example 4: Here is an easier way:
View Full Code Here


          <w:r/>
          <w:r>
            <w:fldChar w:fldCharType="end"/>
          </w:r>
        </w:p>         */       
        P paragraphForTOC = factory.createP();          
        R r = factory.createR();

        FldChar fldchar = factory.createFldChar();
        fldchar.setFldCharType(STFldCharType.BEGIN);
        fldchar.setDirty(true);
        r.getContent().add(getWrappedFldChar(fldchar));
        paragraphForTOC.getContent().add(r);

        R r1 = factory.createR();
        Text txt = new Text();
        txt.setSpace("preserve");
        txt.setValue("TOC \\o \"1-3\" \\h \\z \\u \\h");
        r.getContent().add(factory.createRInstrText(txt) );
        paragraphForTOC.getContent().add(r1);

        FldChar fldcharend = factory.createFldChar();
        fldcharend.setFldCharType(STFldCharType.END);
        R r2 = factory.createR();
        r2.getContent().add(getWrappedFldChar(fldcharend));
        paragraphForTOC.getContent().add(r2);
           
    body.getContent().add(paragraphForTOC);
   
    documentPart.addStyledParagraphOfText("Heading1", "Hello 1");
    documentPart.addStyledParagraphOfText("Heading2", "Hello 2");
View Full Code Here

 
  @Override
  public List<Object> apply(Object o) {
   
    if (o instanceof P) {
      P p = (P)o;
      if ( p.getPPr()!=null && p.getPPr().getSectPr()!=null ) {
//        System.out.println("Found sectpr!");
        sectPrList.add(p.getPPr().getSectPr());
      }
    }
    return null;
  }
View Full Code Here

    // Example 1: add text in Title style
    mdp.addStyledParagraphOfText("Title", "Select all, then hit F9 in Word to see your pictures, or programmatically add them first");
   
    mdp.createParagraphOfText("simple field:");
   
    P p = new P();
    p.getContent().add(
        createSimpleField( " INCLUDEPICTURE  \"file:///C:/Users/jharrop/git/plutext/docx4j/src/test/resources/images/greentick.png\"  \\* MERGEFORMAT ")
        );
    mdp.getContent().add(p);

    mdp.createParagraphOfText("complex field:");
   
    p = new P();
    addComplexField(p, " INCLUDEPICTURE  \"file:///C:/Users/jharrop/git/plutext/docx4j/src/test/resources/images/greentick.png\"  \\* MERGEFORMAT ");
    mdp.getContent().add(p);
     
   
       // Pretty print the main document part
View Full Code Here

              +"<w:r>"
                +"<w:t>More stuff.</w:t>"
              +"</w:r>"
            +"</w:p>";
     
      P pIn = (P)XmlUtils.unmarshalString(pString);
     
      XPathAwareCloner cloner = new XPathAwareCloner();
      P clonedP = (P)cloner.deepCopy(pIn);
     
      List<Object> results = cloner.getJAXBNodesViaXPath("//w:r[contains( w:t, 'seeking')]", false);
      //List<Object> results = cloner.getJAXBNodesViaXPath("//w:r", false);
     
      int i=1;
View Full Code Here

    ndp.setJaxbElement( (Numbering) XmlUtils.unmarshalString(initialNumbering) );
   
    // Add some document content
    wordMLPackage.getMainDocumentPart().addParagraphOfText("Example of restarting numbering");
   
    P p = createNumberedParagraph(1, 0, "text on top level" );
      wordMLPackage.getMainDocumentPart().addObject(p);
   
      wordMLPackage.getMainDocumentPart().addObject(
          createNumberedParagraph(1, 0, "more text on top level" ));
   
View Full Code Here

   * @return
   */
  private static P createNumberedParagraph(long numId, long ilvl, String paragraphText ) {
   
    P  p = factory.createP();

    org.docx4j.wml.Text  t = factory.createText();
    t.setValue(paragraphText);

    org.docx4j.wml.R  run = factory.createR();
    run.getContent().add(t);   
   
    p.getContent().add(run);
           
      org.docx4j.wml.PPr ppr = factory.createPPr();     
      p.setPPr( ppr );
     
      // Create and add <w:numPr>
      NumPr numPr =  factory.createPPrBaseNumPr();
      ppr.setNumPr(numPr);
     
View Full Code Here

    String outputfilepath = "data/docx4j/Docx4j_BookmarkAdd.docx";   

    wordMLPackage.getMainDocumentPart().addParagraphOfText("x");
    wordMLPackage.getMainDocumentPart().addParagraphOfText("x");
    wordMLPackage.getMainDocumentPart().addParagraphOfText("hello world");
    P p = (P)wordMLPackage.getMainDocumentPart().getContent().get(2);
    R r = (R)p.getContent().get(0);

    String bookmarkName = "abcd";
    bookmarkRun(p,r, bookmarkName, 123);

    wordMLPackage.getMainDocumentPart().addParagraphOfText("x");
View Full Code Here

    Comment theComment = createComment(commentId, "fred", null,
        "my first comment");
    comments.getComment().add(theComment);

    // Add comment reference to document
    P paraToCommentOn = wordMLPackage.getMainDocumentPart()
        .addParagraphOfText("here is some content");
    paraToCommentOn.getContent().add(createRunCommentReference(commentId));

    // ++, for next comment ...
    commentId = commentId.add(java.math.BigInteger.ONE);

    wordMLPackage.save(new java.io.File(outputfilepath));
View Full Code Here

TOP

Related Classes of org.docx4j.wml.P

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.