Free Support Forum - aspose.com

Add text to end of footer

Hello,


I need to add some text at the end of the primary footer. The following code writes the text at the top of the footer - I don’t know how to write at the end of it, would love to know how :

DocumentBuilder bulder = new DocumentBuilder(doc);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.Write(“This text should be at the end of the footer”);

Thank you!

Hi

Thanks for your request. You can use code like the following to achieve what you need:

Document doc = new Document(@"Test001\in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

// If the footer alredy contans some content,

// we should move DocumentBuidler cursor to the end of footer.

builder.MoveTo(builder.CurrentStory.LastParagraph);

// Uncomment this line of code if the text should be inserted as a separate paragraph.

// builder.Writeln();

builder.Write("This text should be at the end of the footer");

doc.Save(@"Test001\out.doc");

Hope this helps.

Best regards,

Thanks, it worked !