GetAllImages
从文档内容返回图像对象集合。
语法
expression.GetAllImages();
expression - 表示 ApiDocumentContent 类的变量。
参数
此方法没有任何参数。
返回值
ApiImage[]
示例
此示例展示如何从文档内容获取图像对象集合。
// Get all images added to the document.
// How to retrieve all images and display the class type of the first one.
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 shape = Api.CreateShape('rect', 100 * 36000, 100 * 36000, fill, stroke);
paragraph.AddDrawing(shape);
paragraph = Api.CreateParagraph();
const logoUrl = 'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png';
let image = Api.CreateImage(logoUrl, 95 * 36000, 45 * 36000);
paragraph.AddDrawing(image);
let docContent = shape.GetDocContent();
docContent.AddElement(0, paragraph);
let images = docContent.GetAllImages();
let classType = images[0].GetClassType();
paragraph = Api.CreateParagraph();
paragraph.AddText('Class type: ' + classType);
doc.Push(paragraph);