We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I insert headers and footers in a document?

Platform: WinForms |
Control: DocIO |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

Section.HeadersFooters property is used to set the document headers and footers. We can insert document elements like images and tables inside the header and footer. Here is a code snippet that demonstrates the usage.

C#

 // Creating a new document.

WordDocument doc = new WordDocument();

// Add a new section to the document.

IWSection section = doc.AddSection();

// Add a new paragraph for header to the document.

 IWParagraph headerPar = new WParagraph(doc);

 // Add the paragraph to the header section.

section.HeadersFooters.Header.Paragraphs.Add(headerPar);

// Add a new paragraph for header to the document.

IWParagraph footerPar = new WParagraph(doc);

 // Add the paragraph to the Footer section. section.HeadersFooters.Footer.Paragraphs.Add(footerPar)

 

VB

 '' Creating a new document.

Dim doc As WordDocument = New WordDocument()

'' Add a new section to the document.

Dim section As IWSection = doc.AddSection()

'' Add a new paragraph for header to the document.

Dim headerPar As IWParagraph = New WParagraph(doc)

'' Add the paragraph to the header section.

CType(section.HeadersFooters.Header.Paragraphs, WParagraphCollection).Add(headerPar)

'' Add the paragraph to the Footer section.

CType(section.HeadersFooters.Footer.Paragraphs, WParagraphCollection).Add(footerPar)

 

Here is the sample.

Header And Footer.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon