代表圖片的 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 | 如果沒有連結,則傳回 Link 或 null 。 |
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) | Link | 將 Link 設為指定的 Slide ,連結是由指定的投影片 ID 設定。 |
setLinkSlide(slidePosition) | Link | 使用投影片的相對位置,將 Link 設為指定的 Slide 。 |
setLinkUrl(url) | Link | 將 Link 設為指定的非空白網址字串。 |
setRotation(angle) | Image | 設定元素在中心點周圍的順時針旋轉角度。 |
setTitle(title) | Image | 設定網頁元素的替代文字標題。 |
setTop(top) | Image | 設定元素的垂直位置,在元素未旋轉時從頁面左上角測量。 |
setTransform(transform) | Image | 使用提供的轉換設定頁面元素的轉換。 |
setWidth(width) | Image | 設定元素在點的寬度,當元素未旋轉時,元素定界框的寬度。 |
內容詳盡的說明文件
alignOnPage(alignmentPosition)
將元素與網頁上的指定對齊位置對齊。
參數
名稱 | 類型 | 說明 |
---|---|---|
alignmentPosition | AlignmentPosition | 網頁元素與網頁上對齊的位置。 |
回攻員
Image
— 此頁面元素,用於鏈結。
bringForward()
bringToFront()
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 網域可能暫時適用更嚴格的配額。
參數
名稱 | 類型 | 說明 |
---|---|---|
contentType | String | 要轉換的 MIME 類型。對多數 blob 而言,'application/pdf' 是唯一的有效選項。如果是 BMP、GIF、JPEG 或 PNG 格式的圖片,'image/bmp' 、'image/gif' 、'image/jpeg' 或 'image/png' 中的任一個也是有效的格式。 |
回攻員
Blob
:資料做為 blob。
getBlob()
getBorder()
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()
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
getLink()
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()
getParentPage()
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()
preconcatenateTransform(transform)
預先整合提供的轉換與頁面元素的現有轉換。
newTransform = argument * existingTransform
舉例來說,如要將網頁元素移動到左側 36:
element.preconcatenateTransform(SlidesApp.newAffineTransformBuilder() .setTranslateX(-36.0) .build());
此外,您也可以將頁面元素的轉換取代為 setTransform(transform)
。
參數
名稱 | 類型 | 說明 |
---|---|---|
transform | AffineTransform | 要預先串連到這個頁面元素的轉換。 |
回攻員
Image
— 此頁面元素,用於鏈結。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
remove()
移除網頁元素。
如果在移除作業之後,Group
只包含一或多個網頁元素,系統也會移除群組本身。
如果移除主要或版面配置的預留位置 PageElement
,則所有空白的繼承預留位置也會一併移除。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
removeLink()
移除 Link
。
shape.removeLink();
replace(blobSource)
將圖片替換為 BlobSource
物件描述的圖片。
插入圖片後,系統會從
BlobSource
擷取圖片一次,並儲存副本以顯示在簡報中。圖片的大小不得超過 50 MB、不得超過 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);
參數
名稱 | 類型 | 說明 |
---|---|---|
blobSource | BlobSource | 圖片資料。 |
回攻員
Image
:取代後的這個 Image
。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
replace(blobSource, crop)
將這張圖片替換為 Image
物件描述的圖片,並視需要裁剪圖片以符合大小。
插入圖片後,系統會從
BlobSource
擷取圖片一次,並儲存副本以顯示在簡報中。圖片的大小不得超過 50 MB、不得超過 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);
參數
名稱 | 類型 | 說明 |
---|---|---|
blobSource | BlobSource | 圖片資料。 |
crop | Boolean | 如果為 true ,則會根據現有圖片大小裁剪圖片。否則圖片會縮放並置中。 |
回攻員
Image
:取代後的這個 Image
。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
replace(imageUrl)
將這張圖片替換成從提供網址下載的其他圖片。
插入圖片時,您可以從網址擷取圖片一次,系統會儲存副本以顯示在簡報中。圖片大小不得超過 50 MB,且不得超過 2500 萬像素,且必須使用 PNG、JPEG 或 GIF 格式。
提供的網址必須可公開存取,且大小不得超過 2 KB。網址本身會與圖片一起儲存,並透過 getSourceUrl()
公開。
為了維持圖片的長寬比,系統會配合現有圖片大小縮放圖片,並將圖片置中。
參數
名稱 | 類型 | 說明 |
---|---|---|
imageUrl | String | 圖片下載來源網址。 |
回攻員
Image
:取代後的這個 Image
。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
replace(imageUrl, crop)
將這張圖片替換成從提供網址下載的另一個圖片,並視需要裁剪圖片以符合大小。
插入圖片時,您可以從網址擷取圖片一次,系統會儲存副本以顯示在簡報中。圖片大小不得超過 50 MB,且不得超過 2500 萬像素,且必須使用 PNG、JPEG 或 GIF 格式。
提供的網址不得超過 2 KB。
參數
名稱 | 類型 | 說明 |
---|---|---|
imageUrl | String | 圖片下載來源網址。 |
crop | Boolean | 如果為 true ,則會根據現有圖片大小裁剪圖片。否則圖片會縮放並置中。 |
回攻員
Image
:取代後的這個 Image
。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
scaleHeight(ratio)
scaleWidth(ratio)
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
參數選取網頁元素時,必須符合下列條件:
PageElement
物件的父項Page
必須是current page selection
。- 請勿選取多個
Page
物件。
為確保這種情況,最好先使用 Page.selectAsCurrentPage()
選取父項 Page
,然後選取該頁面上的頁面元素。
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); }
參數
名稱 | 類型 | 說明 |
---|---|---|
replace | Boolean | 如為 true ,選取會取代先前的所有選取項目,否則就會新增至先前的任何選取項目。 |
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
sendBackward()
sendToBack()
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());
參數
名稱 | 類型 | 說明 |
---|---|---|
description | String | 用來設定替代文字說明的字串。 |
回攻員
Image
- 這個網頁元素。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
setHeight(height)
setLeft(left)
setLinkSlide(slideIndex)
setLinkSlide(slide)
將 Link
設為指定的 Slide
,連結則是由指定投影片 ID 設定。
// Set a link to the first slide of the presentation. var slide = presentation.getSlides()[0]; shape.setLinkSlide(slide);
參數
名稱 | 類型 | 說明 |
---|---|---|
slide | Slide | 要連結的「Slide 」。 |
回攻員
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
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);
參數
名稱 | 類型 | 說明 |
---|---|---|
slidePosition | SlidePosition | 相對 SlidePosition 。 |
回攻員
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
setLinkUrl(url)
setRotation(angle)
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());
參數
名稱 | 類型 | 說明 |
---|---|---|
title | String | 用來設定替代文字標題的字串。 |
回攻員
Image
- 這個網頁元素。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
setTop(top)
setTransform(transform)
使用提供的轉換設定頁面元素轉換。
更新群組轉換時,系統會變更該群組中頁面元素的絕對轉換,而轉換外觀可能會因此改變。
更新群組中某個頁面元素的轉換,只會變更該頁面元素的轉換;並不會影響群組或群組中其他網頁元素的轉換作業。
如要進一步瞭解轉換作業如何影響網頁元素的視覺外觀,請參閱 getTransform()
。
參數
名稱 | 類型 | 說明 |
---|---|---|
transform | AffineTransform | 為這個網頁元素設定的轉換。 |
回攻員
Image
— 用於鏈結的元素。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations