We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Insert Html text


I need to insert html text into exact coordinates of a .docx document. Is it possible?
And how can I append html text to the current text in all the footers of all the pages in the document?

PD: I have just bought a developer license.


Hi Mariola,

Thanks for your inquiry. You can first move the cursor to the desired node by using DocumentBuider instance prior inserting Text/HTML. Also, you can use the following code to insert Text:

DocumentBuilder builder = new DocumentBuilder();
builder.Write("Simple text");

Moreover, I think you can insert HTML to Headers/Footers by using the following code snippet:

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

// Move cursor to the specific footer and write HTML

builder.InsertHtml("Paragraph right"
+"Implicit paragraph left"
+"Div center" + "Heading 1 left. "); 

doc.Save(MyDir + "DocumentBuilder.InsertHtml Out.doc");

If we can help you with anything else, please feel free to ask.

Best Regards,

Hi Mariola,

Thanks for your inquiry.

Regarding your first request for inserting HTML content at a exact location in a document, I think you can achieve this by using a textbox. Please see the following code.

// Create or open document.
Document doc = new Document();
// Create textbox shape.
Shape textbox = new Shape(doc, ShapeType.TextBox);
textbox.Width = 300;
textbox.Height = 300;
textbox.Stroked = false;
// Define the exact location of where the textbox will be located on the page in points.
textbox.Left = 40;
textbox.Top = 100;
textbox.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
textbox.RelativeVerticalPosition = RelativeVerticalPosition.Page;
// Insert textbox into the document.
// Move to the textbox and insert html content.