I'm trying to add an ellipse to a new docx document:
- Code: Select all
String xmlEllipse = getXmlEllipse();
Object ellipse = XmlUtils.unmarshalString(xmlEllipse);
Graphic ellipseGraphic = (Graphic) ((JAXBElement)ellipse).getValue();
Anchor anchor = new Anchor();
anchor.setGraphic(ellipseGraphic);
ObjectFactory factory = new ObjectFactory();
P paragraph = factory.createP();
R run = factory.createR();
paragraph.getContent().add(run);
Drawing drawing = factory.createDrawing();
run.getContent().add(drawing);
drawing.getAnchorOrInline().add(anchor);
WordprocessingMLPackage newDoc = WordprocessingMLPackage.createPackage();
newDoc.getMainDocumentPart().getContent().add(paragraph);
newDoc.save(new File(dirPath + outputFilePath));
The xml that I'm using for the ellipse is this one:
private static String ...