Textbox and HTML size problems

Dear Aspose support:
Two questions for you:

  1. How to insert a textbox with a bookmark (the bookmark is inside the textbox) by code?
  2. In my project, I called
MoveToBookmark("somebookmark");
InsertHTML("...some multiple rows of HTML text with table etc...");

Are there anyway to calculate how many rows (or vertical height in inch) the client html will take after the insertion?
Thanks in advance,
David

Hi David,

Thanks for your inquiry.

  1. Please use the following code to insert a TextBox Shape with a bookmark in document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape textBox = new Shape(doc, ShapeType.TextBox);
textBox.Width = 300;
textBox.Height = 100;
Paragraph textBoxPara = new Paragraph(doc);
textBox.AppendChild(textBoxPara);
doc.FirstSection.Body.FirstParagraph.AppendChild(textBox);
builder.MoveTo(textBoxPara);
builder.StartBookmark("MyBookmark");
builder.Write("Text inside a bookmark.");
builder.EndBookmark("MyBookmark");
doc.Save(@"C:\Temp\out.docx");
  1. I think, you can implement the following work flow to achieve this:
    a) Create an intermediate empty Word document using Aspose.Words programmatically.
    b) Insert HTML fragment into this document using DocumentBuilder.InsertHtml method.
    c) Use LayoutEnumerator class to calculate number of Lines or heights/widths of those Lines present in this temp document…
    d) Finally, insert this temp document into your main Document at a Bookmark position. Please see the following article:
    https://docs.aspose.com/words/java/insert-and-append-documents/

I hope, this helps.

Best regards,

That really helps, thank you so much!
David