TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

SetHeaderDistance

SetHeaderDistance(nDistance)

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

Parameters:

Name Type Description
nDistance twips

The distance from the top edge of the page to the top edge of the header 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 a header. ");
oParagraph.AddText("Scroll down the page to see it.");
var oSection = oDocument.GetFinalSection();
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).");
builder.SaveFile("docx", "SetHeaderDistance.docx");
builder.CloseFile();

Resulting document