ApiSection
Class representing a document section.
Methods
Name |
Description |
GetClassType |
Returns a type of the ApiSection class. |
GetFooter |
Returns the content for the specified footer type. |
GetHeader |
Returns the content for the specified header type. |
GetNext |
Returns the next section if exists. |
GetPrevious |
Returns the previous section if exists. |
RemoveFooter |
Removes 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 presented. |
RemoveHeader |
Removes 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 presented. |
SetEqualColumns |
Specifies that all the text columns in the current section are of equal width. |
SetFooterDistance |
Specifies the distance from the bottom edge of the page to the bottom edge of the footer. |
SetHeaderDistance |
Specifies the distance from the top edge of the page to the top edge of the header. |
SetNotEqualColumns |
Specifies that all the columns in the current section have the different widths. 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 |
Specifies the page margins for all the pages in this section. |
SetPageSize |
Specifies the properties (size and orientation) for all the pages in the current section. |
SetTitlePage |
Specifies whether the current section in this document has the different header and footer for the section first page. |
SetType |
Specifies a 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.
|
ToJSON |
Converts the ApiSection object into the JSON object. |
Example
Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var 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.");
var oFooter = oSection.GetFooter("default", true);
oSection.SetFooterDistance(1440);
oParagraph = oFooter.GetElement(0);
oParagraph.AddText("This is a page footer. ");
oParagraph.AddText("The distance from the page bottom to the footer is 1 inch (1440 twentieths of a point).");
var oHeader = oSection.GetHeader("default", true);
oSection.SetHeaderDistance(1440);
oParagraph = oHeader.GetElement(0);
oParagraph.AddText("This is a page header. ");
oParagraph.AddText("The distance from the page top to the header is 1 inch (1440 twentieths of a point).");
oSection.SetPageMargins(720, 720, 720, 720);
builder.SaveFile("docx", "ApiSection.docx");
builder.CloseFile();
Resulting document