How to insert circle shape on to an image using Java

Hi Team,

I am using Aspose-Words-Java-16.11 . I want to draw a circle on an image at a given center point with refrence to that image and generate a doc out of that . Can you please help me on that if it is possible using this version.

Thanks

@rubal4005

Could you please ZIP and attach your input and expected output documents? We will then provide you more information about your query along with code example.

snip.PNG (341.1 KB)

Hi Tahir,

Thanks for the quick response i have attached the output file . Can you please take a look at that and provide me the code example. As an input i am getting the background image and the coordinates for the shapes like for circle radius and its center points.

Thanks

@rubal4005

Following code example shows how to insert circle into document at specific place. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentStart();

Shape shape = new Shape(doc, ShapeType.ELLIPSE);
shape.setWidth(50);
shape.setHeight(50);
shape.setLeft(100);
shape.setTop(100);
builder.insertNode(shape);

doc.save(MyDir + "20.3.docx");

If you still face problem, please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

1 Like

Hi @tahir.manzoor,

Thanks for the help , I am able to draw a circle and rectangle with that. I also want to draw a polygon for which i am having like 4 to 5 co-ordinates . can i draw it with aspose ? if yes can you please provide an example for that too.

@rubal4005

You can use ShapeType.PENTAGON as shown below to draw the pentagon. We suggest you please read the members of ShapeType class. Hope this helps you.

Shape shape = new Shape(doc, ShapeType.PENTAGON);