Class InlineDrawing Stay organized with collections Save and categorize content based on your preferences.
Page Summary
An InlineDrawing represents an embedded drawing within a ListItem or Paragraph, unless that parent is within a FootnoteSection, and cannot contain other elements itself.
The InlineDrawing element provides methods to manage its properties and position, such as copying, getting/setting alternate descriptions and titles, retrieving attributes, navigating siblings and parent, determining its type and position, merging, and removing from its parent.
Many of the methods require authorization with specific Google Docs API scopes.
An element representing an embedded drawing. AnInline can be contained within aList orParagraph, unless theList orParagraph is withinaFootnote. AnInline cannot itself contain any other element. Formore information on document structure, see theguide to extending Google Docs.
Methods
| Method | Return type | Brief description |
|---|---|---|
copy() | Inline | Returns a detached, deep copy of the current element. |
get | String|null | Returns the drawing's alternate description. |
get | String|null | Returns the drawing's alternate title. |
get | Object | Retrieves the element's attributes. |
get | Element|null | Retrieves the element's next sibling element. |
get | Container | Retrieves the element's parent element. |
get | Element|null | Retrieves the element's previous sibling element. |
get | Element | Retrieves the element'sElement. |
is | Boolean | Determines whether the element is at the end of theDocument. |
merge() | Inline | Merges the element with the preceding sibling of the same type. |
remove | Inline | Removes the element from its parent. |
set | Inline | Sets the drawing's alternate description. |
set | Inline | Sets the drawing's alternate title. |
set | Inline | Sets the element's attributes. |
Detailed documentation
copy()
Returns a detached, deep copy of the current element.
Any child elements present in the element are also copied. The new element doesn't have aparent.
Return
Inline — The new copy.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
getAltDescription()
Returns the drawing's alternate description.
Return
String|null — The alternate description, ornull if the element does not have an alternate description.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
getAltTitle()
Returns the drawing's alternate title.
Return
String|null — The alternate title, ornull if the element does not have an alternate title.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
getAttributes()
Retrieves the element's attributes.
The result is an object containing a property for each valid element attribute where eachproperty name corresponds to an item in theDocument enumeration.
constdoc=DocumentApp.getActiveDocument();constdocumentTab=doc.getActiveTab().asDocumentTab();constbody=documentTab.getBody();// Append a styled paragraph.constpar=body.appendParagraph('A bold, italicized paragraph.');par.setBold(true);par.setItalic(true);// Retrieve the paragraph's attributes.constatts=par.getAttributes();// Log the paragraph attributes.for(constattinatts){Logger.log(`${att}:${atts[att]}`);}
Return
Object — The element's attributes.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
getNextSibling()
Retrieves the element's next sibling element.
The next sibling has the same parent and follows the current element.
Return
Element|null — The next sibling element.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
getParent()
Retrieves the element's parent element.
The parent element contains the current element.
Return
Container — The parent element.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
getPreviousSibling()
Retrieves the element's previous sibling element.
The previous sibling has the same parent and precedes the current element.
Return
Element|null — The previous sibling element.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
getType()
Retrieves the element'sElement.
Useget to determine the exact type of a given element.
constdoc=DocumentApp.getActiveDocument();constdocumentTab=doc.getActiveTab().asDocumentTab();constbody=documentTab.getBody();// Obtain the first element in the active tab's body.constfirstChild=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.');}
Return
Element — The element type.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
isAtDocumentEnd()
Determines whether the element is at the end of theDocument.
Return
Boolean — Whether the element is at the end of the tab.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
merge()
Merges the element with the preceding sibling of the same type.
Only elements of the sameElement can be merged. Any child elements contained inthe current element are moved to the preceding sibling element.
The current element is removed from the document.
constdoc=DocumentApp.getActiveDocument();constdocumentTab=doc.getActiveTab().asDocumentTab();constbody=documentTab.getBody();// Example 1: Merge paragraphs// Append two paragraphs to the document's active tab.constpar1=body.appendParagraph('Paragraph 1.');constpar2=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.constcells=[['Row 1, Cell 1','Row 1, Cell 2'],['Row 2, Cell 1','Row 2, Cell 2'],];// Build a table from the array.consttable=body.appendTable(cells);// Get the first row in the table.constrow=table.getRow(0);// Get the two cells in this row.constcell1=row.getCell(0);constcell2=row.getCell(1);// Merge the current cell into its preceding sibling element.constmerged=cell2.merge();
Return
Inline — The merged element.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
removeFromParent()
Removes the element from its parent.
constdoc=DocumentApp.getActiveDocument();constdocumentTab=doc.getActiveTab().asDocumentTab();constbody=documentTab.getBody();// Remove all images in the active tab's body.constimgs=body.getImages();for(leti=0;i <imgs.length;i++){imgs[i].removeFromParent();}
Return
Inline — The removed element.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
setAltDescription(description)
Sets the drawing's alternate description. If the given description isnull, sets thedescription to the empty string.
Parameters
| Name | Type | Description |
|---|---|---|
description | String | The alternate description. |
Return
Inline — The current object.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
setAltTitle(title)
Sets the drawing's alternate title. If the given title isnull, sets the title to theempty string.
Parameters
| Name | Type | Description |
|---|---|---|
title | String | The alternate title. |
Return
Inline — The current object.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
setAttributes(attributes)
Sets the element's attributes.
The specified attributes parameter must be an object where each property name is an item intheDocument enumeration and each property value is the new value to beapplied.
constdoc=DocumentApp.getActiveDocument();constdocumentTab=doc.getActiveTab().asDocumentTab();constbody=documentTab.getBody();// Define a custom paragraph style.conststyle={};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.constpar=body.appendParagraph('A paragraph with custom style.');// Apply the custom style.par.setAttributes(style);
Parameters
| Name | Type | Description |
|---|---|---|
attributes | Object | The element's attributes. |
Return
Inline — The current element.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.