Get Started
Documentation

ApiSection

new ApiSection()

Class representing a document section.

Methods

Name Description
GetClassType

Get the type of this class.

GetFooter

Get the content for the specified footer type.

GetHeader

Get the content for the specified header type.

RemoveFooter

Remove the footer of the specified type from the current section. After removal the footer will be inherited from the previous section or, if this is the first section in the document, no footer of the specified type will be present.

RemoveHeader

Remove the header of the specified type from the current section. After removal the header will be inherited from the previous section or, if this is the first section in the document, no header of the specified type will be present.

SetEqualColumns

Specify that all text columns in the current section are of equal width.

SetFooterDistance

Specify the distance from the bottom edge of the page to the bottom edge of the footer.

SetHeaderDistance

Specify the distance from the top edge of the page to the top edge of the header.

SetNotEqualColumns

Specify that all columns in the current section are of a different width. Number of columns is equal to the length of the aWidth array. The length of the aSpaces array MUST BE equal to (aWidth.length - 1).

SetPageMargins

Specify the page margins for all pages in this section.

SetPageSize

Specify the properties (size and orientation) for all pages in the current section.

SetTitlePage

Specify whether the current section in this document have different header and footer for the section first page.

SetType

Specify the type of the current section. The section type defines how the contents of the current section are placed relative to the previous section.
WordprocessingML supports five distinct types of section breaks:

  • Next page section breaks (the default if type is not specified), which begin the new section on the following page.
  • Odd page section breaks, which begin the new section on the next odd-numbered page.
  • Even page section breaks, which begin the new section on the next even-numbered page.
  • Continuous section breaks, which begin the new section on the following paragraph. This means that continuous section breaks might not specify certain page-level section properties, since they shall be inherited from the following section. These breaks, however, can specify other section properties, such as line numbering and footnote/endnote settings.
  • Column section breaks, which begin the new section on the next column on the page.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oHeader;
oParagraph = oDocument.GetElement(0);
var oSection = oDocument.GetFinalSection();
oSection.SetEqualColumns(3, 720);
oParagraph.AddText("This is a text split into 3 equal columns. ");
oParagraph.AddText("The columns are separated by the distance of half an inch.");
oParagraph.AddColumnBreak();
oParagraph.AddText("This text starts from column #2. ");
oParagraph.AddText("This sentence is used to add lines for demonstrative purposes.");
oParagraph.AddColumnBreak();
oParagraph.AddText("This text starts from column #3. ");
oParagraph.AddText("This sentence is used to add lines for demonstrative purposes.");
builder.SaveFile("docx", "SetEqualColumns.docx");
builder.CloseFile();

Resulting document