SetPageMargins

function SetPageMargins(nLeft: twips = null, nTop: twips = null, nRight: twips = null, nBottom: twips = null): void

Description

Specifies the page margins for all the pages in this section.

Parameters

nLefttwipsdefault: null

The left margin width measured in twentieths of a point (1/1440 of an inch).

nToptwipsdefault: null

The top margin height measured in twentieths of a point (1/1440 of an inch).

nRighttwipsdefault: null

The right margin width measured in twentieths of a point (1/1440 of an inch).

nBottomtwipsdefault: null

The bottom margin height measured in twentieths of a point (1/1440 of an inch).

Returns

void

Try It

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);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).