跳到主要内容

GetClassType

返回 ApiDocumentContent 类的类型。

语法

expression.GetClassType();

expression - 表示 ApiDocumentContent 类的变量。

参数

此方法没有任何参数。

返回值

"documentContent"

示例

检索文档中文档内容对象的类类型。

// How do I identify what type a document content object is in a document?

// Confirm whether a shape's inner container is a document content before processing it further.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let drawing = Api.CreateShape("rect", 3212465, 963295, fill, stroke);
paragraph.AddDrawing(drawing);
let docContent = drawing.GetDocContent();
docContent.RemoveAllElements();
paragraph = Api.CreateParagraph();
paragraph.SetJc("left");
paragraph.AddText("We removed all elements from the shape and added a new paragraph inside it.");
docContent.AddElement(0, paragraph);
let classType = docContent.GetClassType();
paragraph = Api.CreateParagraph();
paragraph.AddText("Class Type = " + classType);
doc.Push(paragraph);