Stay organized with collections Save and categorize content based on your preferences.
PositionedImageFixed position image anchored to a Paragraph
. Unlike an InlineImage
, a PositionedImage
is not an Element
. It does not have a parent or sibling Element
. Instead, it is anchored to a Paragraph
or ListItem
, and is placed via offsets from that anchor. A PositionedImage
has an ID that can be used to reference it.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Append a new paragraph. const paragraph = body.appendParagraph('New paragraph to anchor the image to.'); // Get an image in Drive from its ID. const image = DriveApp.getFileById('ENTER_IMAGE_FILE_ID_HERE').getBlob(); // Add the PositionedImage with offsets (in points). const posImage = paragraph.addPositionedImage(image).setTopOffset(60).setLeftOffset(40);Methods Method Return type Brief description
getAs(contentType)
Blob
Return the data inside this object as a blob converted to the specified content type. getBlob()
Blob
Return the data inside this object as a blob. getHeight()
Integer
Retrieves the image's height, in pixels. getId()
String
Gets the image's ID. getLayout()
PositionedLayout
Gets an enum value that represents how the image is laid out. getLeftOffset()
Number
Gets the image's offset, in points, from the paragraph's left. getParagraph()
Paragraph
Gets the Paragraph
the image is anchored to. getTopOffset()
Number
Gets the image's offset, in points, from the paragraph's top. getWidth()
Integer
Retrieves the image's width, in pixels. setHeight(height)
PositionedImage
Sets the image's height, in pixels. setLayout(layout)
PositionedImage
Sets the definition of how the image is laid out. setLeftOffset(offset)
PositionedImage
Sets the image's offset, in points, from the paragraph's left. setTopOffset(offset)
PositionedImage
Sets the image's offset, in points, from the paragraph's top. setWidth(width)
PositionedImage
Sets the image's width, in pixels. Detailed documentation 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 DescriptioncontentType
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.
getBlob()
Return the data inside this object as a blob.
ReturnBlob
— The data as a blob.
getHeight()
Retrieves the image's height, in pixels.
ReturnInteger
— the image's height, in pixels
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getId()
Gets the image's ID.
ReturnString
— the image ID
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getLayout()
Gets an enum value that represents how the image is laid out.
ReturnPositionedLayout
— the image layout
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getLeftOffset()
Gets the image's offset, in points, from the paragraph's left.
ReturnNumber
— the image offset from the left paragraph's left
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getParagraph()
Gets the Paragraph
the image is anchored to.
Paragraph
— the parent paragraph
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getTopOffset()
Gets the image's offset, in points, from the paragraph's top.
ReturnNumber
— the image offset from the left paragraph's top
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getWidth()
Retrieves the image's width, in pixels.
ReturnInteger
— the image's width, in pixels
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
setHeight(height)
Sets the image's height, in pixels.
Parameters Name Type Descriptionheight
Integer
the image's height, in pixels Return
PositionedImage
— the current object
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
setLayout(layout)
Sets the definition of how the image is laid out.
Parameters Name Type Descriptionlayout
PositionedLayout
an enum representing the layout mode Return
PositionedImage
— this object for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
setLeftOffset(offset)
Sets the image's offset, in points, from the paragraph's left.
Parameters Name Type Descriptionoffset
Number
offset from the paragraph's left Return
PositionedImage
— this object for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
setTopOffset(offset)
Sets the image's offset, in points, from the paragraph's top.
Parameters Name Type Descriptionoffset
Number
offset from the paragraph's top Return
PositionedImage
— this object for chaining
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
setWidth(width)
Sets the image's width, in pixels.
Parameters Name Type Descriptionwidth
Integer
the image's width, in pixels Return
PositionedImage
— the current object
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
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 2024-12-02 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 2024-12-02 UTC."],[[["A `PositionedImage` is anchored to a Paragraph or ListItem and positioned using offsets, unlike an InlineImage which is treated as an Element."],["It's placed relative to its anchor (Paragraph or ListItem) using `setLeftOffset()` and `setTopOffset()` methods, specifying distances in points."],["You can manipulate its dimensions using methods like `setWidth()`, `setHeight()`, and retrieve image data with `getBlob()` or `getAs()`."],["The `PositionedImage` object has an ID for referencing and allows you to control its layout using the `setLayout()` method."]]],[]]
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