Free Support Forum - aspose.com

How to insert TextBox

Dear Support,

1. how to insert a Word TextBox

2. can i insert HTML or Table into the TextBox?

thanks

Please see the following code. I think that it could be useful for you.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//Insert Textbox into the table

Shape textBox = new Shape(doc, ShapeType.TextBox);

Paragraph par = new Paragraph(doc);

Run run = new Run(doc, string.Empty);

par.AppendChild(run);

textBox.AppendChild(par);

doc.FirstSection.Body.FirstParagraph.AppendChild(textBox);

//Move cursor inside the textbox

builder.MoveTo(par);

//Insert table

for (int i = 0; i < 5; i++)

{

for (int j = 0; j < 5; j++)

{

builder.InsertCell();

}

builder.EndRow();

}

builder.EndTable();

doc.Save(@"Test046\out.doc");

Also note that best way to build table using Aspose.Words is using DocumentBuilder but not inserting HTML.

Best regards.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Yes, of course this works. I think that you should just specify size of textbox:

//Insert Textbox into the table

Shape textBox = new Shape(doc, ShapeType.TextBox);

textBox.Width = 100;

textBox.Height = 100;

Hope this helps.

Best regards.