A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/apps-script/reference/document/inline-image.html below:

Class InlineImage | Apps Script

Skip to main content Class InlineImage

Stay organized with collections Save and categorize content based on your preferences.

InlineImage

An element representing an embedded image. An InlineImage can be contained within a ListItem or Paragraph, unless the ListItem or Paragraph is within a FootnoteSection. An InlineImage cannot itself contain any other element. For more information on document structure, see the guide to extending Google Docs.

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 a parent.

Return

InlineImage — The new copy.

Scripts that use this method require authorization with one or more of the following scopes:

getAltDescription()

Returns the image's alternate description.

Return

String — The alternate description, or null if the element does not have an alternate description.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getAltTitle()

Returns the image's alternate title.

Return

String — The alternate title, or null if the element does not have an alternate title.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getAs(contentType)

Return the data inside this object as a blob converted to the specified content type. This method adds the appropriate extension to the filename—for example, "myfile.pdf". However, it assumes that the part of the filename that follows the last period (if any) is an existing extension that should be replaced. Consequently, "ShoppingList.12.25.2014" becomes "ShoppingList.12.25.pdf".

To view the daily quotas for conversions, see Quotas for Google Services. Newly created Google Workspace domains might be temporarily subject to stricter quotas.

Parameters Name Type Description contentType String The MIME type to convert to. For most blobs, 'application/pdf' is the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of 'image/bmp', 'image/gif', 'image/jpeg', or 'image/png' are also valid. For a Google Docs document, 'text/markdown' is also valid. Return

Blob — The data as a blob.

getAttributes()

Retrieves the element's attributes.

The result is an object containing a property for each valid element attribute where each property name corresponds to an item in the DocumentApp.Attribute enumeration.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Append a styled paragraph.
const par = body.appendParagraph('A bold, italicized paragraph.');
par.setBold(true);
par.setItalic(true);

// Retrieve the paragraph's attributes.
const atts = par.getAttributes();

// Log the paragraph attributes.
for (const att in atts) {
  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 following scopes:

getBlob()

Return the data inside this object as a blob.

Return

Blob — The data as a blob.

getHeight()

Retrieves the image's height, in pixels.

Return

Integer — the image's height, in pixels

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getLinkUrl()

Retrieves the link URL.

Return

String — The link URL, or null if the element contains multiple values for this attribute.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getNextSibling()

Retrieves the element's next sibling element.

The next sibling has the same parent and follows the current element.

Return

Element — The next sibling element.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getParent()

Retrieves the element's parent element.

The parent element contains the current element.

Return

ContainerElement — The parent element.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getPreviousSibling()

Retrieves the element's previous sibling element.

The previous sibling has the same parent and precedes the current element.

Return

Element — The previous sibling element.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getType()

Retrieves the element's ElementType.

Use getType() to determine the exact type of a given element.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Obtain the first element in the active tab's body.

const 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.');
}
Return

ElementType — The element type.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getWidth()

Retrieves the image's width, in pixels.

Return

Integer — the image's width, in pixels

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

isAtDocumentEnd()

Determines whether the element is at the end of the Document.

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 following scopes:

merge()

Merges the element with the preceding sibling of the same type.

Only elements of the same ElementType can be merged. Any child elements contained in the current element are moved to the preceding sibling element.

The current element is removed from the document.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Example 1: Merge paragraphs
// Append two paragraphs to the document's active tab.
const par1 = body.appendParagraph('Paragraph 1.');
const 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.
const cells = [
  ['Row 1, Cell 1', 'Row 1, Cell 2'],
  ['Row 2, Cell 1', 'Row 2, Cell 2'],
];
// Build a table from the array.
const table = body.appendTable(cells);
// Get the first row in the table.
const row = table.getRow(0);
// Get the two cells in this row.
const cell1 = row.getCell(0);
const cell2 = row.getCell(1);
// Merge the current cell into its preceding sibling element.
const merged = cell2.merge();
Return

InlineImage — The merged element.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

removeFromParent()

Removes the element from its parent.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Remove all images in the active tab's body.
const imgs = body.getImages();
for (let i = 0; i < imgs.length; i++) {
  imgs[i].removeFromParent();
}
Return

InlineImage — The removed element.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

setAltDescription(description)

Sets the image's alternate description. If the given title is null, sets the description to the empty string.

Parameters Name Type Description description String The alternate description. Return

InlineImage — The current object.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

setAltTitle(title)

Sets the image's alternate title. If the given title is null, sets the title to the empty string.

Parameters Name Type Description title String The alternate title. Return

InlineImage — The current object.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

setAttributes(attributes)

Sets the element's attributes.

The specified attributes parameter must be an object where each property name is an item in the DocumentApp.Attribute enumeration and each property value is the new value to be applied.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Define a custom paragraph style.
const 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.
const par = 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

InlineImage — The current element.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

setHeight(height)

Sets the image's height, in pixels.

Parameters Name Type Description height Integer the image's height, in pixels Return

InlineImage — the current object

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

setLinkUrl(url)

Sets the link URL. When the given URL is null or an empty string, this method creates a link with an empty URL that may display as "Invalid link" in Google Docs.

Parameters Name Type Description url String The link URL. Return

InlineImage — The current object.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

setWidth(width)

Sets the image's width, in pixels.

Parameters Name Type Description width Integer the image's width, in pixels Return

InlineImage — the current object

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-04 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-04 UTC."],[[["The `InlineImage` element represents an embedded image within a Google Doc, allowing for manipulation of its properties, data, and relationships within the document structure."],["Developers can access and modify image data, dimensions, linking, and other attributes using dedicated methods provided by the Apps Script API."],["Using `InlineImage` element methods requires authorization scopes like `https://www.googleapis.com/auth/documents.currentonly` or `https://www.googleapis.com/auth/documents`."],["While versatile, `InlineImage` has limitations, such as nesting restrictions and content type conversion quotas, which developers should be aware of."],["Navigation within the document and manipulation of the element itself are facilitated through methods like `getParent()`, `copy()`, `merge()`, and `removeFromParent()`, enabling dynamic control over the image's placement and behavior."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4