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

Free Support Forum - aspose.com

Bookmark append text

Hi,

I have scenario where I print text on selected bookmarks. I need to append the text with styles when I use bookmarks. Please advise…

In the below example…the bookmark1 should be like
bookmark 2 text 1 bookmark 2 text 2

DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("bookmark1);
builder.Font.Bold = true;
bodyBuilder.Font.Italic = true;
bodyBuilder.Write("bookmark 2 text 1);

builder.MoveToBookmark("bookmark2);
builder.Font.Bold = true;
bodyBuilder.Write("bookmark 2 text 1);

builder.MoveToBookmark("bookmark1);
builder.Font.Underline= true;
bodyBuilder.Write("bookmark 2 text 2);




Hi there,

Thanks for your inquiry. Please check the following code example. Hope this helps you.

If you still face problem, please share your input and expected output documents here for our reference. We will then provide you more information about your query along with code.

Document doc = new Document(MyDir + "in.docx");

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToBookmark("bookmark1");

builder.Font.Bold = true;

builder.Font.Italic = true;

builder.Write("bookmark 1 text 1");

builder.Font.ClearFormatting();

builder.Font.Underline = Underline.Single;

builder.MoveToBookmark("bookmark2");

builder.Write("bookmark 2 text 1");

doc.Save(MyDir + @"output.docx");

My question is little differnt, taking your sample code, I have choose bookmark1 again to print another text, which should append with previous text. Please note that bookmark1 should contain 2 text with different style.


Document doc = new Document(MyDir + "in.docx");

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToBookmark("bookmark1");

builder.Font.Bold = true;

builder.Font.Italic = true;

builder.Write("bookmark 1 text 1");

builder.Font.ClearFormatting();

builder.Font.Underline = Underline.Single;

builder.MoveToBookmark("bookmark2");

builder.Write("bookmark 2 text 1");


builder.MoveToBookmark("bookmark1");

builder.Font.Underline = true;

builder.Write("bookmark 1 text 1");

doc.Save(MyDir + @"output.docx");

Never mind, I understand that is word property.

Hi there,

Thanks for your inquiry. If your problem has not resolved yet, please share your input and expected output documents here for our reference. We will then provide you more information about your query along with code.