跳到主要内容

GetHeader

返回指定页眉类型的内容。

语法

expression.GetHeader(sType, isCreate);

expression - 表示 ApiSection 类的变量。

参数

名称必需/可选数据类型默认值描述
sType必需HdrFtrType要获取内容的页眉类型。
isCreate可选booleanfalse指定在当前节中找不到指定类型的页眉时,是否创建新的页眉。

返回值

ApiDocumentContent

示例

访问文档中节的页眉区域。

// How do I retrieve the header from a specific section in a document?

// Open the header region to add or inspect text that appears at the top of pages in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is a page with a header. ");
paragraph.AddText("See it above.");
let section = doc.GetFinalSection();
let header = section.GetHeader("default", true);
paragraph = header.GetElement(0);
paragraph.AddText("This is a page header");