Class Image

图片

表示图像的 PageElement

方法

方法返回类型简介
alignOnPage(alignmentPosition)Image将元素与页面上的指定对齐位置对齐。
bringForward()Image将页面上的页面元素前移一个元素。
bringToFront()Image将页面元素置于页面开头。
duplicate()PageElement复制页面元素。
getAs(contentType)Blob将此对象中的数据作为转换为指定内容类型的 blob 返回。
getBlob()Blob以 blob 的形式返回该图片中的数据。
getBorder()Border返回图片的 Border
getConnectionSites()ConnectionSite[]返回页面元素上的 ConnectionSite 列表;如果页面,则返回空列表 元素没有任何连接站点。
getContentUrl()String获取图片的网址。
getDescription()String返回页面元素的替代文本说明。
getHeight()Number获取元素的高度(以点为单位),也就是在 元素没有旋转。
getInherentHeight()Number返回元素的固有高度(以点为单位)。
getInherentWidth()Number返回元素的固有宽度(以点为单位)。
getLeft()Number返回元素的水平位置,以点为单位,从 页面。
getLink()Link如果没有链接,则返回 Linknull
getObjectId()String返回此对象的唯一 ID。
getPageElementType()PageElementType返回页面元素的类型,以 PageElementType 枚举表示。
getParentGroup()Group返回此页面元素所属的组,或者返回 null(如果该元素不在 。
getParentPage()Page返回此页面元素所在的页面。
getParentPlaceholder()PageElement返回占位符的父页面元素。
getPlaceholderIndex()Integer返回占位符图片的索引。
getPlaceholderType()PlaceholderType返回图片的占位符类型,如果形状不是,则返回 PlaceholderType.NONE 占位符。
getRotation()Number返回元素围绕其中心顺时针旋转的角度(以度为单位),其中 0 度 表示不旋转。
getSourceUrl()String获取图片的来源网址(如果有)。
getTitle()String返回页面元素的替代文本标题。
getTop()Number获取元素的垂直位置(以点为单位),从页面左上角开始测量。 当元素没有旋转时。
getTransform()AffineTransform返回页面元素的转换。
getWidth()Number返回元素的宽度(以点为单位),也就是在 则该元素未旋转。
preconcatenateTransform(transform)Image将提供的转换与页面元素的现有转换进行预串联。
remove()void移除页面元素。
removeLink()void移除 Link
replace(blobSource)Image将此图片替换为由 BlobSource 对象描述的图片。
replace(blobSource, crop)Image将此图片替换为由 Image 对象描述的图片,并视需要剪裁 调整到合适的大小。
replace(imageUrl)Image将此图片替换为从提供的网址下载的其他图片。
replace(imageUrl, crop)Image将此图片替换为从提供的网址下载的其他图片,可选择进行剪裁 调整到合适的大小。
scaleHeight(ratio)Image按指定的比例缩放元素的高度。
scaleWidth(ratio)Image按指定的比例缩放元素的宽度。
select()void仅选择当前演示文稿中的PageElement,并移除之前的所有文档 选择。
select(replace)void选择当前演示文稿中的 PageElement
sendBackward()Image将页面元素向后发送一个元素。
sendToBack()Image将页面元素发送到页面后端。
setDescription(description)Image设置页面元素的替代文本说明。
setHeight(height)Image设置元素的高度(以点为单位),这是指在 元素没有旋转。
setLeft(left)Image设置元素的水平位置(以点为单位),从 页面。
setLinkSlide(slideIndex)Link使用幻灯片的索引(从零开始)将 Link 设置为指定的 Slide
setLinkSlide(slide)LinkLink 设置为指定的 Slide,链接由指定的幻灯片 ID 设置。
setLinkSlide(slidePosition)Link使用幻灯片的相对位置将 Link 设置为指定的 Slide
setLinkUrl(url)LinkLink 设置为给定的非空网址字符串。
setRotation(angle)Image设置元素围绕其中心顺时针旋转的角度(以度为单位)。
setTitle(title)Image设置页面元素的替代文本标题。
setTop(top)Image设置元素的垂直位置(以点为单位),从页面左上角开始测量 当元素没有旋转时。
setTransform(transform)Image使用提供的转换设置页面元素的转换。
setWidth(width)Image设置元素的宽度(以点为单位),即在 元素没有旋转。

详细文档

alignOnPage(alignmentPosition)

将元素与页面上的指定对齐位置对齐。

参数

名称类型说明
alignmentPositionAlignmentPosition此页面元素在网页上的对齐位置。

返回

Image - 此页面元素,用于链接。


bringForward()

将页面上的页面元素前移一个元素。

页面元素不得位于组中。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

bringToFront()

将页面元素置于页面开头。

页面元素不得位于组中。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

duplicate()

复制页面元素。

重复的网页元素会与原始网页元素置于同一位置。

返回

PageElement - 此页面元素的新副本。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getAs(contentType)

将此对象中的数据作为转换为指定内容类型的 blob 返回。本次 方法会为文件名添加相应的扩展名,例如“myfile.pdf”。不过, 最后一个句点之后的文件名部分(如果有)假定存在 扩展名。因此,“ShoppingList.12.25.2014”会变为 “ShoppingList.12.25.pdf”。

要查看转化次数的每日配额,请参阅 Google 配额 服务。新创建的 Google Workspace 网域可能会暂时适用更严格的条件 配额。

参数

名称类型说明
contentTypeString要转换为的 MIME 类型。对于大多数 blob,'application/pdf' 为 唯一有效的选项对于 BMP、GIF、JPEG 或 PNG 格式的图片,'image/bmp''image/gif''image/jpeg''image/png' 中的任何一个也 有效。对于 Google 文档,'text/markdown' 也有效。

返回

Blob - 以 blob 形式表示的数据。


getBlob()

以 blob 的形式返回该图片中的数据。

返回

Blob - 以 blob 形式表示的图片数据。


getBorder()

返回图片的 Border

返回

Border - 图片的边框。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getConnectionSites()

返回页面元素上的 ConnectionSite 列表;如果页面,则返回空列表 元素没有任何连接站点。

返回

ConnectionSite[] - 连接站点列表,如果此元素没有连接站点,则可能为空。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getContentUrl()

获取图片的网址。

此网址使用请求者的账号进行标记,因此知道该网址的任何人 以原始请求者身份访问图片。如果出现意外情况, 演示文稿的共享设置发生变化。返回的网址会在一小段时间后过期。

返回

String

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getDescription()

返回页面元素的替代文本说明。系统会将说明与标题相结合 显示和读出替代文本。

返回

String - 页面元素的替代文本说明。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getHeight()

获取元素的高度(以点为单位),也就是在 元素没有旋转。

此方法并非与所有页面元素都兼容。了解哪些页面元素 是否兼容此方法,请参阅 大小和位置限制

返回

Number - 页面元素的固有高度,以点为单位;如果页面元素高度,则为 null 没有高度。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getInherentHeight()

返回元素的固有高度(以点为单位)。

页面元素的转换是相对于其固有大小而言的。使用 与元素的转换结合使用,以确定元素的最终视觉外观。

返回

Number - 页面元素的固有高度,以点为单位;如果页面元素高度,则为 null 没有高度。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getInherentWidth()

返回元素的固有宽度(以点为单位)。

页面元素的转换是相对于其固有大小而言的。使用 与元素的转换结合使用,以确定元素的最终视觉外观。

返回

Number - 页面元素的固有宽度(以点为单位),或者如果页面元素宽度为 null 且未设置宽度

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getLeft()

返回元素的水平位置,以点为单位,从 页面。

返回

Number - 此元素的水平位置,以点为单位,从页面左上角开始。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

如果没有链接,则返回 Linknull

var link = shape.getLink();
if (link != null) {
  Logger.log('Shape has a link of type: ' + link.getLinkType());
}

返回

Link

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getObjectId()

返回此对象的唯一 ID。页面和页面元素使用的对象 ID 共享 同一个命名空间

返回

String - 此对象的唯一 ID。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPageElementType()

返回页面元素的类型,以 PageElementType 枚举表示。

返回

PageElementType - 页面元素的类型。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getParentGroup()

返回此页面元素所属的组,或者返回 null(如果该元素不在 。

返回

Group - 此页面元素所属的组或 null

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getParentPage()

返回此页面元素所在的页面。

返回

Page - 此元素所在的页面。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getParentPlaceholder()

返回占位符的父页面元素。如果图片并非null 占位符或没有父级。

返回

PageElement - 此图片占位符的父页面元素;如果此图片不是null 占位符或没有父级。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPlaceholderIndex()

返回占位符图片的索引。如果同一网页上有两张或更多占位符图片 类型相同,但它们都拥有唯一的索引值。如果图片并非null 占位符。

返回

Integer - 表示该图片的占位符索引,如果图片不是占位符,则为 null

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPlaceholderType()

返回图片的占位符类型,如果形状不是,则返回 PlaceholderType.NONE 占位符。

返回

PlaceholderType - 此图片的占位符类型。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getRotation()

返回元素围绕其中心顺时针旋转的角度(以度为单位),其中 0 度 表示不旋转。

返回

Number - 介于 0(含)和 360(不含)之间的旋转角度(以度为单位)。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getSourceUrl()

获取图片的来源网址(如果有)。

如果通过网址插入图片,则返回在插入图片期间提供的网址。

返回

String - 图片网址;如果图片没有来源网址,则为 null

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTitle()

返回页面元素的替代文本标题。将商品名与说明相结合 显示和读出替代文本。

返回

String - 页面元素的替代文本标题。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTop()

获取元素的垂直位置(以点为单位),从页面左上角开始测量。 当元素没有旋转时。

返回

Number - 此元素的垂直位置,以点为单位,从页面左上角开始。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTransform()

返回页面元素的转换。

页面元素的视觉外观由其绝对转换决定。接收者 计算绝对转换,将页面元素的转换与转换预串联起来 所有父级群组的数据。如果页面元素不在组中,则其绝对转换为 与此字段中的值相同。

返回

AffineTransform - 页面元素的转换。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getWidth()

返回元素的宽度(以点为单位),也就是在 则该元素未旋转。

此方法并非与所有页面元素都兼容。了解哪些页面元素 是否兼容此方法,请参阅 大小和位置限制

返回

Number - 页面元素的固有宽度(以点为单位),或者如果页面元素宽度为 null 且未设置宽度

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

preconcatenateTransform(transform)

将提供的转换与页面元素的现有转换进行预串联。

newTransform = argument * existingTransform

例如,要将页面元素向左移动 36 点:

element.preconcatenateTransform(SlidesApp.newAffineTransformBuilder()
    .setTranslateX(-36.0)
    .build());

您还可以将页面元素的转换替换为 setTransform(transform)

参数

名称类型说明
transformAffineTransform要预串到此页面元素的转换上的转换。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

remove()

移除页面元素。

如果在执行 remove 操作后,Group 仅包含一个页面元素或不包含任何页面元素, 也会被移除

如果从母版或版式上移除了占位符 PageElement,则任何空的继承关系 占位符也会被移除。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

移除 Link

shape.removeLink();

replace(blobSource)

将此图片替换为由 BlobSource 对象描述的图片。

插入图片会从 BlobSource,并且会存储一份副本,以便在演示文稿中显示。 图片必须小于 50MB,不能超过 2500 万像素,并且必须 PNG、JPEG 或 GIF 格式。

为了保持图像的纵横比,图像将按一定比例缩放和居中。 调整为现有图片的尺寸。

var image = SlidesApp.getActivePresentation().getSlides()[0].getImages()[0];
// Get the Drive image file with the given ID.
var driveImage = DriveApp.getFileById(fileId);
image.replace(driveImage);

参数

名称类型说明
blobSourceBlobSource图片数据。

返回

Image - 替换后此 Image

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

replace(blobSource, crop)

将此图片替换为由 Image 对象描述的图片,并视需要剪裁 调整到合适的大小。

插入图片会从 BlobSource,并且会存储一份副本,以便在演示文稿中显示。 图片必须小于 50MB,不能超过 2500 万像素,并且必须 PNG、JPEG 或 GIF 格式。

var image = SlidesApp.getActivePresentation().getSlides()[0].getImages()[0];
// Get the Drive image file with the given ID.
var driveImage = DriveApp.getFileById(fileId);
// Replace and crop the drive image.
image.replace(driveImage, true);

参数

名称类型说明
blobSourceBlobSource图片数据。
cropBoolean如果为 true,则剪裁图片以适应现有图片的大小。否则, 调整图片大小并居中放置。

返回

Image - 替换后此 Image

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

replace(imageUrl)

将此图片替换为从提供的网址下载的其他图片。

插入图片即会从网址抓取一次,然后会存储一个副本以便在 演示文稿。图片必须小于 50MB,不能超过 2500 万像素, 格式为 PNG、JPEG 或 GIF 格式。

提供的网址必须可公开访问,且大小不得超过 2kB。网址本身已保存 图片,并通过 getSourceUrl() 公开。

为了保持图像的纵横比,图像将按一定比例缩放和居中。 调整为现有图片的尺寸。

参数

名称类型说明
imageUrlString用于下载图片的网址。

返回

Image - 替换后此 Image

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

replace(imageUrl, crop)

将此图片替换为从提供的网址下载的其他图片,可选择进行剪裁 调整到合适的大小。

插入图片即会从网址抓取一次,然后会存储一个副本以便在 演示文稿。图片必须小于 50MB,不能超过 2500 万像素, 格式为 PNG、JPEG 或 GIF 格式。

提供的网址不得超过 2kB。

参数

名称类型说明
imageUrlString用于下载图片的网址。
cropBoolean如果为 true,则剪裁图片以适应现有图片的大小。否则, 调整图片大小并居中放置。

返回

Image - 替换后此 Image

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

scaleHeight(ratio)

按指定的比例缩放元素的高度。元素的高度是指其高度 边框。

此方法并非与所有页面元素都兼容。了解哪些页面元素 是否兼容此方法,请参阅 大小和位置限制

参数

名称类型说明
ratioNumber此页面元素的高度所依据的比率。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

scaleWidth(ratio)

按指定的比例缩放元素的宽度。元素的宽度是其 边框。

此方法并非与所有页面元素都兼容。了解哪些页面元素 是否兼容此方法,请参阅 大小和位置限制

参数

名称类型说明
ratioNumber此页面元素的宽度比率。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

select()

仅选择当前演示文稿中的PageElement,并移除之前的所有文档 选择。这与使用 true 调用 select(replace) 相同。

脚本只能访问运行脚本的用户的选择,并且只有在 该脚本就会绑定到演示文稿。

这会将 PageElement 的父级 Page 设置为 current page selection

var slide = SlidesApp.getActivePresentation().getSlides()[0];
var pageElement = slide.getPageElements()[0];
// Only select this page element and replace any previous selection.
pageElement.select();

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

select(replace)

选择当前演示文稿中的 PageElement

脚本只能访问运行脚本的用户的选择,并且只有在 该脚本就会绑定到演示文稿。

true 传递给此方法,仅选择 PageElement 并移除任意子属性 上一个选择。这还会将 PageElement 的父级 Page 设置为 current page selection

传递 false 以选择多个 PageElement 对象。PageElement 对象必须位于同一 Page 中。

使用 false 选择页面元素时,必须满足以下条件 参数:

  1. PageElement 对象的父级 Page 必须是 current page selection
  2. 不应选择多个 Page 对象。

为此,首选方法是选择父级 Page 先使用 Page.selectAsCurrentPage(),然后选择该页面中的页面元素。

var slide = SlidesApp.getActivePresentation().getSlides()[0];
// First select the slide page, as the current page selection.
slide.selectAsCurrentPage();
// Then select all the page elements in the selected slide page.
var pageElements = slide.getPageElements();
for (var i = 0; i < pageElements.length; i++) {
  pageElements[i].select(false);
}

参数

名称类型说明
replaceBoolean如果为 true,则所选内容将替换之前的任何选择;否则 都会添加到之前的所有所选内容中。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

sendBackward()

将页面元素向后发送一个元素。

页面元素不得位于组中。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

sendToBack()

将页面元素发送到页面后端。

页面元素不得位于组中。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setDescription(description)

设置页面元素的替代文本说明。

Group 元素不支持此方法。

// Set the first page element's alt text description to "new alt text description".
var pageElement = SlidesApp.getActivePresentation().getSlides()[0].getPageElements()[0];
pageElement.setDescription('new alt text description');
Logger.log(pageElement.getDescription());

参数

名称类型说明
descriptionString要为替代文本说明设置的字符串。

返回

Image - 此页面元素。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setHeight(height)

设置元素的高度(以点为单位),这是指在 元素没有旋转。

此方法并非与所有页面元素都兼容。了解哪些页面元素 是否兼容此方法,请参阅 大小和位置限制

参数

名称类型说明
heightNumber要设置的页面元素的新高度(以点为单位)。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setLeft(left)

设置元素的水平位置(以点为单位),从 页面。

参数

名称类型说明
leftNumber要设置的新水平位置(以点为单位)。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setLinkSlide(slideIndex)

使用幻灯片的索引(从零开始)将 Link 设置为指定的 Slide

// Set a link to the first slide of the presentation.
shape.setLinkSlide(0);

参数

名称类型说明
slideIndexInteger幻灯片的索引(从零开始)。

返回

Link - 设置的 Link

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setLinkSlide(slide)

Link 设置为指定的 Slide,链接由指定的幻灯片 ID 设置。

// Set a link to the first slide of the presentation.
var slide = presentation.getSlides()[0];
shape.setLinkSlide(slide);

参数

名称类型说明
slideSlide要关联的 Slide

返回

Link - 设置的 Link

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setLinkSlide(slidePosition)

使用幻灯片的相对位置将 Link 设置为指定的 Slide

// Set a link to the first slide of the presentation.
shape.setLinkSlide(SlideApp.SlidePosition.FIRST_SLIDE);

参数

名称类型说明
slidePositionSlidePosition相对 SlidePosition

返回

Link - 设置的 Link

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setLinkUrl(url)

Link 设置为给定的非空网址字符串。

// Set a link to the URL.
shape.setLinkUrl("https://slides.google.com");

参数

名称类型说明
urlString网址字符串。

返回

Link - 设置的 Link

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setRotation(angle)

设置元素围绕其中心顺时针旋转的角度(以度为单位)。

此方法并非与所有页面元素都兼容。了解哪些页面元素 是否兼容此方法,请参阅 大小和位置限制

参数

名称类型说明
angleNumber要设置的新顺时针旋转角度(以度为单位)。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setTitle(title)

设置页面元素的替代文本标题。

Group 元素不支持此方法。

// Set the first page element's alt text title to "new alt text title".
var pageElement = SlidesApp.getActivePresentation().getSlides()[0].getPageElements()[0];
pageElement.setTitle('new alt text title');
Logger.log(pageElement.getTitle());

参数

名称类型说明
titleString要为替代文本标题设置的字符串。

返回

Image - 此页面元素。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setTop(top)

设置元素的垂直位置(以点为单位),从页面左上角开始测量 当元素没有旋转时。

参数

名称类型说明
topNumber要设置的新垂直位置(以点为单位)。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setTransform(transform)

使用提供的转换设置页面元素的转换。

更新组的转换会更改 中页面元素的绝对转换 这可能会改变其视觉外观。

更新组内页面元素的转换只会改变 该页面元素不会影响该组或 。

如需详细了解转换如何影响页面元素的视觉外观,请参阅 getTransform()

参数

名称类型说明
transformAffineTransform为此页面元素设置的转换。

返回

Image - 此元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

setWidth(width)

设置元素的宽度(以点为单位),即在 元素没有旋转。

此方法并非与所有页面元素都兼容。了解哪些页面元素 是否兼容此方法,请参阅 大小和位置限制

参数

名称类型说明
widthNumber要设置的页面元素的新宽度(以点为单位)。

返回

Image - 此页面元素,用于链接。

授权

使用此方法的脚本需要获得以下一个或多个范围的授权:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations