Hi,
I would like to ask for support in the following scenario.
- Create document
- Insert new section (2 sections in document in total)
- Move to 1st section, then move to header.
- Insert bookmark
- Move to 2nd section, then move to header.
- Insert bookmark (with same details as earlier)
Important note
The bookmarks are added in both section (check HeaderFooter.Range.Bookmarks)
Then try to save document as docx (I noticed it saving just as file and when using memory stream) - the bookmark is removed then.
var document = new Document();
DocumentBuilder documentBuilder = new DocumentBuilder(document);
documentBuilder.Document.Sections.Add(new Section(documentBuilder.Document));
documentBuilder.MoveToSection(0);
documentBuilder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
documentBuilder.StartBookmark("ABC123");
documentBuilder.Write("TEXT");
documentBuilder.EndBookmark("ABC123");
documentBuilder.MoveToSection(1);
documentBuilder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
documentBuilder.StartBookmark("ABC123");
documentBuilder.Write("TEXT");
documentBuilder.EndBookmark("ABC123");
using (var stream = new MemoryStream())
{
documentBuilder.Document.Save(stream, SaveFormat.Docx);
}
Could you check my scenario? Could you provide any workaround for that?
Thanks