Class InlineDrawing

InlineDrawing

埋め込み図形描画を表す要素。InlineDrawing は、ListItem または ParagraphFootnoteSection 内にある場合を除き、ListItem または Paragraph 内に含めることができます。InlineDrawing 自体に他の要素を含めることはできません。ドキュメント構造について詳しくは、Google ドキュメントの拡張ガイドをご覧ください。

Methods

メソッド戻り値の型概要
copy()InlineDrawing現在の要素の分離されたディープコピーを返します。
getAltDescription()String図形描画の代替の説明を返します。
getAltTitle()String図形描画の代替タイトルを返します。
getAttributes()Object要素の属性を取得します。
getNextSibling()Element要素の次の兄弟要素を取得します。
getParent()ContainerElement要素の親要素を取得します。
getPreviousSibling()Element要素の前の兄弟要素を取得します。
getType()ElementType要素の ElementType を取得します。
isAtDocumentEnd()Boolean要素が Document の末尾にあるかどうかを判断します。
merge()InlineDrawing要素を、前の同じタイプの兄弟要素と結合します。
removeFromParent()InlineDrawing要素を親から削除します。
setAltDescription(description)InlineDrawing図形描画の代替説明を設定します。
setAltTitle(title)InlineDrawing図形描画の代替タイトルを設定します。
setAttributes(attributes)InlineDrawing要素の属性を設定します。

詳細なドキュメント

copy()

現在の要素の分離されたディープコピーを返します。

その要素内にある子要素もコピーされます。新しい要素には親がありません。

リターン

InlineDrawing - 新しいコピー。

承認

この方法を使用するスクリプトには、次の 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

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

getNextSibling()

要素の次の兄弟要素を取得します。

次の兄弟要素は同じ親を持ち、現在の要素をフォローします。

リターン

Element - 次の兄弟要素。

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

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

getParent()

要素の親要素を取得します。

親要素には現在の要素が含まれます。

リターン

ContainerElement - 親要素。

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

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

getPreviousSibling()

要素の前の兄弟要素を取得します。

前の兄弟要素は同じ親を持ち、現在の要素の前にあります。

リターン

Element - 前の兄弟要素。

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

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

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

isAtDocumentEnd()

要素が Document の末尾にあるかどうかを判断します。

リターン

Boolean - 要素がドキュメントの末尾にあるかどうか。

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

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

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();

リターン

InlineDrawing - 結合された要素。

承認

この方法を使用するスクリプトには、次の 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();
}

リターン

InlineDrawing - 削除された要素。

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

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

setAltDescription(description)

図形描画の代替説明を設定します。指定されたタイトルが null の場合、説明を空の文字列に設定します。

パラメータ

名前説明
descriptionString代替タイトル

リターン

InlineDrawing - 現在のオブジェクト

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

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

setAltTitle(title)

図形描画の代替タイトルを設定します。指定されたタイトルが null の場合、タイトルを空の文字列に設定します。

パラメータ

名前説明
titleString代替タイトル

リターン

InlineDrawing - 現在のオブジェクト

承認

この方法を使用するスクリプトには、次の 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);

パラメータ

名前説明
attributesObject要素の属性。

リターン

InlineDrawing - 現在の要素。

承認

この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。

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