Get Started
Documentation

SetType

SetType(sType)

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 specification 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 will 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.

Parameters:

Name Type Description
sType "nextPage" | "oddPage" | "evenPage" | "continuous" | "nextColumn" Type of the section break.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oFooter;
oParagraph = oDocument.GetElement(0);
var oSection = oDocument.CreateSection(oParagraph);
oParagraph.AddText("This is section #1 of the document. ");
var oSection = oDocument.GetFinalSection();
oSection.SetType("continuous");
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is section #2 and we set 'Continuous' type to it. ");
oParagraph.AddText("As you can see, the section is not on a new page. ");
oParagraph.AddText("If this section had some other type (nextPage, oddPage, evenPage), it would start a new page.");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "SetType.docx");
builder.CloseFile();

Resulting document