Free Support Forum - aspose.com

Header and footer lost after replace with section break

Hi,

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");

@Pluriform_Software,

We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-22353. We will further look into the details of this problem and will keep you updated here on the status. We apologize for any inconvenience.