List<Object> children = p.getParagraphContent();
List<Object> children = getParagraphContent();
public static int[] getParagraphRunTextWordCounts(P p) { List<Object> children = p.getParagraphContent();
private static org.docx4j.wml.R createRunStructure(String textVal, P existingP, int rIndex ) { org.docx4j.wml.R newR = wmlFactory.createR(); org.docx4j.wml.Text newT = wmlFactory.createText(); newR.getRunContent().add(newT); newT.setValue(textVal); newT.setSpace("preserve"); org.docx4j.wml.RPr existingRPr = ((org.docx4j.wml.R)existingP.getParagraphContent().get(rIndex)).getRPr(); if ( existingRPr !=null ) newR.setRPr(existingRPr); return newR; }
p.getParagraphContent().add(r);
newLeftP.getParagraphContent().addAll(pLeftReplacement); newRightP.getParagraphContent().addAll(pRightReplacement);
List<Object> children = p.getParagraphContent();
List<Object> children = getParagraphContent();
public static int[] getParagraphRunTextWordCounts(P p) { List<Object> children = p.getParagraphContent();
private static org.docx4j.wml.R createRunStructure(String textVal, P existingP, int rIndex ) { org.docx4j.wml.R newR = wmlFactory.createR(); org.docx4j.wml.Text newT = wmlFactory.createText(); newR.getRunContent().add(newT); newT.setValue(textVal); newT.setSpace("preserve"); org.docx4j.wml.RPr existingRPr = ((org.docx4j.wml.R)existingP.getParagraphContent().get(rIndex)).getRPr(); if ( existingRPr !=null ) newR.setRPr(existingRPr); return newR; }
p.getParagraphContent().add(r);
newLeftP.getParagraphContent().addAll(pLeftReplacement); newRightP.getParagraphContent().addAll(pRightReplacement);
ObjectFactory factory = Context.getWmlObjectFactory(); R run = factory.createR(); Text text1 = factory.createText(); text1.setValue("asd"); run.getContent().add(text1); Br nl = factory.createBr(); run.getContent().add(nl); Text text2 = factory.createText(); text2.setValue("efg"); run.getContent().add(text2); P para = factory.createP(); para.getParagraphContent().add(run); WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(); wordMLPackage.getMainDocumentPart().addObject(para); wordMLPackage.getMainDocumentPart().addParagraphOfText("p1"); wordMLPackage.getMainDocumentPart().addParagraphOfText("p2"); wordMLPackage.save(new File("test.docx"));
ObjectFactory factory = Context.getWmlObjectFactory(); CTSimpleField ctSimple = factory.createCTSimpleField(); ctSimple.setInstr(" MergeField fieldValue \\* MERGEFORMAT "); RPr RPr = factory.createRPr(); RPr.setNoProof(new BooleanDefaultTrue()); Text t = factory.createText(); t.setValue("fieldValue"); R run = factory.createR(); run.getRunContent().add(RPr); run.getRunContent().add(t); ctSimple.getParagraphContent().add(run); JAXBElement<CTSimpleField> fldSimple = factory .createPFldSimple(ctSimple); // P P para = factory.createP(); para.getParagraphContent().add(fldSimple); Body body = factory.createBody(); body.getEGBlockLevelElts().add(para); wordMLPackage.getMainDocumentPart().addObject(body);