We are using the Range.Replace method to replace text in our documents. One of the features provided by the find and replace API is the ability to replace text with metacharacters.
We are experiencing problems when using the SectionBreak (&b) meta character in combination with headers and/or footers. If this character is used the header and/or footer will be removed from the first section and fixed to the second section.
I can’t quite get a grip if this is by design or not. My expectation is that the original header and footer stays on the original section and the header and footer of the new section is ‘linked to previous’ since this is a newly created section?
Please find source code below.
DocumentBuilder builder = new DocumentBuilder(document); builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary); builder.Write("HEADER"); builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary); builder.Write("FOOTER"); builder.MoveToDocumentEnd(); builder.Writeln("Section One[break]Section Two"); document.Range.Replace("[break]", "&b");