Hello Aspose Teams, I want to ask about drawing an image.
Hi Ano Rangga,
Thanks for your inquiry. Please use the following code example to achieve your requirements. Hope this helps you. I have attached the output document with this post for your kind reference. Please get the code of insertWatermarkText from here:
http://www.aspose.com/docs/display/wordsjava/How+to++Add+a+Watermark+to+a+Document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = new Shape(doc, ShapeType.TEXT_BOX);
shape.setWidth(doc.getFirstSection().getPageSetup().getPageWidth() - 100);
shape.setHeight(doc.getFirstSection().getPageSetup().getPageHeight()- 100);
shape.setWrapType(WrapType.NONE);
shape.setBehindText(true);
shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
shape.setHorizontalAlignment(HorizontalAlignment.CENTER);
shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
shape.setVerticalAlignment(VerticalAlignment.CENTER);
shape.setStroked(true);
shape.setStrokeColor(Color.yellow);
shape.setStrokeWeight(1);
shape.appendChild(new Paragraph(doc));
Paragraph para = shape.getFirstParagraph();
para.appendChild(new Run(doc, ""));
builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
builder.insertNode(shape);
insertWatermarkText(doc, "WaterMark");
builder.moveTo(para);
Shape image = builder.insertImage(MyDir + "in.png");
para.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
doc.save(MyDir + "Out.docx");