埋め込み画像を表す要素。InlineImage
は、ListItem
または Paragraph
が FootnoteSection
内にある場合を除き、ListItem
または Paragraph
内に格納できます。InlineImage
自体に他の要素を含めることはできません。ドキュメント構造の詳細については、Google ドキュメントの拡張ガイドをご覧ください。
Methods
方法 | 戻り値の型 | 概要 |
---|---|---|
copy() | InlineImage | 現在の要素から分離されたディープコピーを返します。 |
getAltDescription() | String | 画像の代替の説明を返します。 |
getAltTitle() | String | 画像の代替タイトルを返します。 |
getAs(contentType) | Blob | このオブジェクト内のデータを、指定されたコンテンツ タイプに変換した blob として返します。 |
getAttributes() | Object | 要素の属性を取得します。 |
getBlob() | Blob | このオブジェクト内のデータを blob として返します。 |
getHeight() | Integer | ピクセル単位の画像の高さを取得します。 |
getLinkUrl() | String | リンク URL を取得します。 |
getNextSibling() | Element | 要素の次の兄弟要素を取得します。 |
getParent() | ContainerElement | 要素の親要素を取得します。 |
getPreviousSibling() | Element | 要素の前の兄弟要素を取得します。 |
getType() | ElementType | 要素の ElementType を取得します。 |
getWidth() | Integer | 画像の幅(ピクセル単位)を取得します。 |
isAtDocumentEnd() | Boolean | 要素が Document の末尾にあるかどうかを判断します。 |
merge() | InlineImage | 同じタイプの先行する兄弟要素と要素を結合します。 |
removeFromParent() | InlineImage | 親から要素を削除します。 |
setAltDescription(description) | InlineImage | 画像の代替の説明を設定します。 |
setAltTitle(title) | InlineImage | 画像の代替タイトルを設定します。 |
setAttributes(attributes) | InlineImage | 要素の属性を設定します。 |
setHeight(height) | InlineImage | 画像の高さをピクセル単位で設定します。 |
setLinkUrl(url) | InlineImage | リンク URL を設定します。 |
setWidth(width) | InlineImage | 画像の幅をピクセル単位で設定します。 |
詳細なドキュメント
copy()
現在の要素から分離されたディープコピーを返します。
その要素内のすべての子要素もコピーされます。新しい要素には親がありません。
戻る
InlineImage
- 新しいコピー。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAltDescription()
画像の代替の説明を返します。
戻る
String
- 代替タイトル。または、要素に代替タイトルがない場合は null
。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAltTitle()
画像の代替タイトルを返します。
戻る
String
- 代替タイトル。または、要素に代替タイトルがない場合は null
。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAs(contentType)
このオブジェクト内のデータを、指定されたコンテンツ タイプに変換した blob として返します。このメソッドは、ファイル名に適切な拡張子を追加します(例: &filet;myfile.pdf")。ただし、最後のピリオド(ある場合)に続くファイル名の部分は既存の拡張機能であり、置き換える必要があります。したがって、「ShoppingList.12.25.2014」は「ShoppingList.12.25.pdf"」になります。
1 日あたりのコンバージョンの割り当てを確認するには、Google サービスの割り当てをご覧ください。新しく作成された Google Workspace ドメインは、より厳密な割り当ての適用を一時的に受けることがあります。
パラメータ
名前 | 型 | 説明 |
---|---|---|
contentType | String | 変換先の MIME タイプ。ほとんどの blob では、'application/pdf' が唯一の有効なオプションです。BMP、GIF、JPEG、PNG 形式の画像の場合、'image/bmp' 、'image/gif' 、'image/jpeg' 、'image/png' のいずれかも有効です。 |
戻る
Blob
- blob としてのデータ。
getAttributes()
要素の属性を取得します。
結果は、各プロパティ名が DocumentApp.Attribute
列挙型のアイテムに対応する、有効な要素属性のプロパティを含むオブジェクトになります。
var body = DocumentApp.getActiveDocument().getBody(); // Append a styled paragraph. var par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. var atts = par.getAttributes(); // Log the paragraph attributes. for (var att in atts) { Logger.log(att + ":" + atts[att]); }
戻る
Object
- 要素の属性。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getBlob()
getHeight()
ピクセル単位の画像の高さを取得します。
戻る
Integer
- 画像の高さ(ピクセル単位)
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLinkUrl()
リンク URL を取得します。
戻る
String
- リンク URL。この属性に値が複数ある場合は null
を指定します。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNextSibling()
getParent()
要素の親要素を取得します。
親要素には現在の要素が含まれます。
戻る
ContainerElement
- 親要素。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPreviousSibling()
getType()
要素の ElementType
を取得します。
getType()
を使用して、特定の要素の正確な型を特定します。
var body = DocumentApp.getActiveDocument().getBody(); // Obtain the first element in the document body. var firstChild = body.getChild(0); // Use getType() to determine the element's type. if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) { Logger.log('The first element is a paragraph.'); } else { Logger.log('The first element is not a paragraph.'); }
戻る
ElementType
- 要素タイプ。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getWidth()
画像の幅(ピクセル単位)を取得します。
戻る
Integer
- 画像の幅(ピクセル単位)
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isAtDocumentEnd()
merge()
同じタイプの先行する兄弟要素と要素を結合します。
統合できるのは、同じ ElementType
の要素のみです。現在の要素に含まれている子要素は、前の兄弟要素に移動されます。
現在の要素がドキュメントから削除されます。
var body = DocumentApp.getActiveDocument().getBody(); // Example 1: Merge paragraphs // Append two paragraphs to the document. var par1 = body.appendParagraph('Paragraph 1.'); var par2 = body.appendParagraph('Paragraph 2.'); // Merge the newly added paragraphs into a single paragraph. par2.merge(); // Example 2: Merge table cells // Create a two-dimensional array containing the table's cell contents. var cells = [ ['Row 1, Cell 1', 'Row 1, Cell 2'], ['Row 2, Cell 1', 'Row 2, Cell 2'] ]; // Build a table from the array. var table = body.appendTable(cells); // Get the first row in the table. var row = table.getRow(0); // Get the two cells in this row. var cell1 = row.getCell(0); var cell2 = row.getCell(1); // Merge the current cell into its preceding sibling element. var merged = cell2.merge();
戻る
InlineImage
- マージされた要素。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
removeFromParent()
親から要素を削除します。
var body = DocumentApp.getActiveDocument().getBody(); // Remove all images in the document body. var imgs = body.getImages(); for (var i = 0; i < imgs.length; i++) { imgs[i].removeFromParent(); }
戻る
InlineImage
- 削除された要素。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAltDescription(description)
画像の代替の説明を設定します。指定されたタイトルが null
の場合、説明を空の文字列に設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
description | String | 代替タイトル |
戻る
InlineImage
- 現在のオブジェクト。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAltTitle(title)
画像の代替タイトルを設定します。指定されたタイトルが null
の場合、タイトルを空の文字列に設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | 代替タイトル |
戻る
InlineImage
- 現在のオブジェクト。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAttributes(attributes)
要素の属性を設定します。
指定する属性パラメータは、各プロパティ名が DocumentApp.Attribute
列挙型の項目であり、各プロパティ値が適用する新しい値であるオブジェクトである必要があります。
var body = DocumentApp.getActiveDocument().getBody(); // Define a custom paragraph style. var style = {}; style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT; style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri'; style[DocumentApp.Attribute.FONT_SIZE] = 18; style[DocumentApp.Attribute.BOLD] = true; // Append a plain paragraph. var par = body.appendParagraph('A paragraph with custom style.'); // Apply the custom style. par.setAttributes(style);
パラメータ
名前 | 型 | 説明 |
---|---|---|
attributes | Object | 要素の属性。 |
戻る
InlineImage
- 現在の要素。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setHeight(height)
画像の高さをピクセル単位で設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
height | Integer | 画像の高さ(ピクセル単位) |
戻る
InlineImage
- 現在のオブジェクト。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setLinkUrl(url)
リンク URL を設定します。指定された URL が null
または空の文字列である場合、このメソッドは空の URL とリンクを作成して、Google ドキュメントに「無効なリンク」と表示します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
url | String | リンク URL です。 |
戻る
InlineImage
- 現在のオブジェクト。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setWidth(width)
画像の幅をピクセル単位で設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
width | Integer | 画像の幅(ピクセル単位) |
戻る
InlineImage
- 現在のオブジェクト。
認可
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents