Border-radius - InsertHTML Mail Merge Word

Hi All - I want to replace a merge tag with the below HTML that creates a circle, it works fine in the HTML viewer, but when it gets merged it creates a square in the document.

<div style="width:20px;height: 20px;border-radius: 100px;background-color:blue;"></div>

Thanks,
Mitesh

@mitesh.prajapati <div> tag is imported as a paragraph to Aspose.Words DOM. So the border is drawn around the whole paragraph in MS Word document and border options are limited to what is available in MS Word. This is an expected behavior.

what would be the other option? the end goal is to create a circle or any other shape through CSS.

@mitesh.prajapati In your case you can use SVG image to insert a circle. For example, like this:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="28.813" height="28.813">
	<g>
		<circle fill="#E83816" stroke="#E61E19" cx="14.406" cy="14.406" r="13.906"/>
	</g>
</svg>

You can use this SVG in your HTML, Aspose.Words will insert it as a shape:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" width=\"28.813\" height=\"28.813\"><g><circle fill=\"#E83816\" stroke=\"#E61E19\" cx=\"14.406\" cy=\"14.406\" r=\"13.906\"/></g></svg>");
doc.Save(@"C:\Temp\out.docx");

The above code produces the following output: out.docx (8.4 KB)

Hi @alexey.noskov - Thanks for your reply, Can we keep the size of the circle based on the font size of the merge field? would that be possible?

@mitesh.prajapati In this case you can simply use a symbolic font, for exampel Wingdings:

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

builder.Font.Name = "Wingdings";
builder.Font.Size = 10;
builder.Write("\x006C");
builder.Font.Size = 20;
builder.Write("\x006C");
builder.Font.Size = 30;
builder.Write("\x006C");

doc.Save(@"C:\Temp\out.docx");

out.docx (7.0 KB)

Hi @alexey.noskov - this may not work as I need to replace HTML as I have a word setup document and just need to replace/merge the tags.

any other solution you can think of?

Thanks,
Mitesh

@mitesh.prajapati You can do the same with HTML:

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

builder.InsertHtml("<span style=\"font-family:Wingdings; font-size:10pt\">&#x006C;</span><span style=\"font-family:Wingdings; font-size:20pt\">&#x006C;</span><span style=\"font-family:Wingdings; font-size:30pt\">&#x006C;</span>");

doc.Save(@"C:\Temp\out.docx");
1 Like

Thanks! this worked for me.

1 Like