How to Insert Header and Footer in DOCX using C++

In this example, we will explore how to insert Header and Footer in DOCX using C++. Header and Footer are added on top and bottom of Word document pages respectively. They hold key and useful information that has purpose to repeat on every page including Date Time, Author Information, Page number etc. In order to use C++ to add Header and Footer information in Word Document, very simple API interface is used.

  1. Download Aspose.Words.Cpp using NuGet package Manager
  2. Include reference to Aspose::Words namespace
  3. Instantiate Document Class object to load the document for adding Header/Footer
  4. Use DocumentBuilder Class to manage Header/Footer settings inside DOCX
  5. Set different Header/Footer properties
  6. Save the DOCX with Header/Footer information in C++ by using Save method

You can use the following example to load any existing MS Word file or create a new one to add Header and Footer information using C++. It shall take only few API calls in C++ to load the document and enable header and footer settings in DOCX.

In previous example, we looked in to How to Create Table in DOCX using C++. Whereas in this example, we have focused on Word document header and footer processing in C++.

 English