Hi,
I am trying to replace the contents of a bookmark and retain the original format using the following code (based on your example) but the formatting changes.
Section tempSection = doc.AddSection();
navigator.MoveToBookmark(placeHolder);
var paragraph = tempSection.AddParagraph();
// Populate paragraph content
ParagraphBase firstReplacementParagraph = tempSection.Paragraphs[0].Items.FirstItem as ParagraphBase;
ParagraphBase lastReplacementParagraph = tempSection.Paragraphs[tempSection.Paragraphs.Count - 1].Items.LastItem as ParagraphBase;
TextBodySelection selection = new TextBodySelection(firstReplacementParagraph, lastReplacementParagraph);
TextBodyPart part = new TextBodyPart(selection);
navigator.DeleteBookmarkContent(true);
navigator.ReplaceBookmarkContent(part);
doc.Sections.Remove(tempSection);
Is there a way I can preserve the formatting? There may be several paragraphs that are added at the bookmark location.
Thanks
S