Manipulating Headers

Hello,

How would I go about manipulating a second-page header? In the attached template, I have “Different first page” selected in the header setup, and I’ve set a default header on the second page, then deleted the page (so I currently have one page in the template). I’d like to programmatically modify the text of the header. Please advise.

Thank you.

Hi George,

Thanks for your inquiry. You can use the following code:

Document doc = new Document(MyDir + @"cover_page_template.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.Write("New Text");
doc.Save(MyDir + @"16.3.0.docx");

Hope, this helps.

In case of any troubles, please attach your expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will then provide you code to achieve the same using Aspose.Words.

Best regards,