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

# How to replace text in document's footer

Hi Aspose Team,

I need to replace footer content into document which contains around 120-150 pages without performance issue to generate a document

So, I preferred in my application to replace a text in footer content while using find and replace document footer using get document.range - replace method.

Is this replace method approach in a sequential process?
how this find and replace works internally in document?

Thanks & Regards
Shyamala

@Shyamu If you need to replace text only in the document’s footer, you do not need to use Document.Range, you can replace text only in the document’s footer range. For example see the following code:

Document doc = new Document(@"C:\Temp\in.docx");
{
// Here you can also check HeaderFooter type to replace text only in a specific header or footer.
hf.Range.Replace("old text", "new cool text");
}
doc.Save(@"C:\Temp\out.docx");


Thanks Alexey !!

In this approach, Document footer range should replace a new text instead of old text in a sequential process as updating a footer in document page one by one.

is there any possibility to replace an expected text in document footer at one shot without streaming document pages one after another?

if not, please provide explanation for “why?”

Regards,
Shyamala

@Shyamu Header and footer are set per section not per page. If your document contains only one section, the code will process maximum 6 nodes, if all types of headers footers present in the document.

Thanks Alexey !!

Footer Text Replace is not working using pattern.compile.

Please refer a sample test package to debug this issue.

Even, I have coded two approaches 1 & 2 to replace footer text. Please suggest me for which approach is fastest one to handle footer text replace more than 50 pages documents?

Regards,
Shyamala B
Footer_Pattern_Test_Package.zip (17.2 KB)

Pattern.compile("[a-zA-Z]{3}\\s\\d{2},(\\s\\d{4})")

for(Section sect : doc.getSections())