SetPageMargins
Specifies the page margins for all the pages in this section.
Parameters:
Name |
Type |
Description |
nLeft |
twips
|
The left margin width measured in twentieths of a point (1/1440 of an inch). |
nTop |
twips
|
The top margin height measured in twentieths of a point (1/1440 of an inch). |
nRight |
twips
|
The right margin width measured in twentieths of a point (1/1440 of an inch). |
nBottom |
twips
|
The bottom margin height measured in twentieths of a point (1/1440 of an inch). |
Returns:
-
This method doesn't return any data.
Example
Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a page with margins set. ");
oParagraph.AddText("The left margin is 5 inches wide (7200 twentieths of a point). ");
oParagraph.AddText("The top margin is 2 inches high (2880 twentieths of a point). ");
oParagraph.AddText("The right margin is 1 inch wide (1440 twentieths of a point). ");
oParagraph.AddText("The bottom margin is 4 inches high (5760 twentieths of a point). ");
var oSection = oDocument.GetFinalSection();
oSection.SetPageMargins(7200, 2880, 1440, 5760);
builder.SaveFile("docx", "SetPageMargins.docx");
builder.CloseFile();
Resulting document