Articles in this section
Category / Section

Is it possible to create different Header and footer in a word document?

1 min read

 

Yes, it is possible to create different header and footer in a document by using the LinkToPrevious property of the Section object. By setting this property as false, we can create different header/footer for each section. Please find the below code snippet to do so

C#

 WParagraph pa = new WParagraph(doc);

pa.AppendText("Page1_Header1");

doc.LastSection.HeadersFooters.Header.Paragraphs.Add(pa);

 doc.AddSection();

 doc.LastSection.HeadersFooters.LinkToPrevious = false;

 pa = new WParagraph(doc);

 pa.AppendText("Second Page _Header2");

 pa.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Right;

doc.LastSection.HeadersFooters.Footer.Paragraphs.Add(pa);

VB

Dim pa As WParagraph = New WParagraph(doc)

pa.AppendText("Page1_Header1")

doc.LastSection.HeadersFooters.Header.Paragraphs.Add(pa)

doc.AddSection()

doc.LastSection.HeadersFooters.LinkToPrevious = False

pa = New WParagraph(doc)

pa.AppendText("Second Page _Header2")

pa.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Right

doc.LastSection.HeadersFooters.Footer.Paragraphs.Add(pa)

http://help.syncfusion.com/samples/KB/DocIOWindows/DifferentHeaderFooter/CS/DifferentHeaderFooter/main.htm

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied