/** * Create a paragraph containing the string simpleText, * and add it to the document. If passed null, the result * is an empty P. * * @param simpleText * @return */ public org.docx4j.wml.P addParagraphOfText(String simpleText) { org.docx4j.wml.P para = createParagraphOfText(simpleText); addObject(para); return para; }
/** * Create a paragraph containing the string simpleText, styled * using the specified style * (up to user to ensure it is a paragraph style) * and add it to the document. * * @param styleId * @param text * @return */ public org.docx4j.wml.P addStyledParagraphOfText(String styleId, String text) { org.docx4j.wml.P p = createStyledParagraphOfText(styleId, text); addObject(p); return p; }
wordMLPackage.getMainDocumentPart().addObject( createSmartArt( layoutRelId, dataRelId, colorsRelId, styleRelId, cx, cy));
/** * Create a paragraph containing the string simpleText, * and add it to the document. If passed null, the result * is an empty P. * * @param simpleText * @return */ public org.docx4j.wml.P addParagraphOfText(String simpleText) { org.docx4j.wml.P para = createParagraphOfText(simpleText); addObject(para); return para; }
/** * Create a paragraph containing the string simpleText, styled * using the specified style * (up to user to ensure it is a paragraph style) * and add it to the document. * * @param styleId * @param text * @return */ public org.docx4j.wml.P addStyledParagraphOfText(String styleId, String text) { org.docx4j.wml.P p = createStyledParagraphOfText(styleId, text); addObject(p); return p; }
/** * Docx4j contains a utility method to create an image part from an array of * bytes and then adds it to the given package. In order to be able to add this * image to a paragraph, we have to convert it into an inline object. For this * there is also a method, which takes a filename hint, an alt-text, two ids * and an indication on whether it should be embedded or linked to. * One id is for the drawing object non-visual properties of the document, and * the second id is for the non visual drawing properties of the picture itself. * Finally we add this inline object to the paragraph and the paragraph to the * main document of the package. * * @param wordMLPackage The package we want to add the image to * @param bytes The bytes of the image * @throws Exception Sadly the createImageInline method throws an Exception * (and not a more specific exception type) * * */ protected static void addImageToPackage(WordprocessingMLPackage wordMLPackage, byte[] bytes) throws Exception { BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes); int docPrId = 1; int cNvPrId = 2; Inline inline = imagePart.createImageInline("Filename hint", "Alternative text", docPrId, cNvPrId, false); P paragraph = addInlineImageToParagraph(inline); wordMLPackage.getMainDocumentPart().addObject(paragraph); }
mainDocumentPart.addObject(table); } else { for (RegionProperty rp : reportRegion.getRegionProperties()) {
wordMLPackage.getMainDocumentPart().addObject( createSmartArt( layoutRelId, dataRelId, colorsRelId, styleRelId, cx, cy));