Class PositionedImage Stay organized with collections Save and categorize content based on your preferences.
Page Summary
A PositionedImage is a fixed position image anchored to a Paragraph or ListItem, unlike an InlineImage which is an Element.
PositionedImages are not considered Elements and do not have parent or sibling Elements.
PositionedImages are placed using offsets from their anchor point and have an ID for referencing.
The provided example code demonstrates how to add a PositionedImage anchored to a new paragraph.
The documentation details various methods for getting and setting properties of a PositionedImage, such as its dimensions, layout, offsets, and associated blob data.
Fixed position image anchored to aParagraph. Unlike anInline, aPositioned isnot anElement. It does not have aparent or siblingElement. Instead,it is anchored to aParagraph orList, and is placed via offsets fromthat anchor. APositioned has an ID that can be used to reference it.
constbody=DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();// Append a new paragraph.constparagraph=body.appendParagraph('New paragraph to anchor the image to.');// Get an image in Drive from its ID.constimage=DriveApp.getFileById('ENTER_IMAGE_FILE_ID_HERE').getBlob();// Add the PositionedImage with offsets (in points).constposImage=paragraph.addPositionedImage(image).setTopOffset(60).setLeftOffset(40);
Methods
| Method | Return type | Brief description |
|---|---|---|
get | Blob | Return the data inside this object as a blob converted to the specified content type. |
get | Blob | Return the data inside this object as a blob. |
get | Integer | Retrieves the image's height, in pixels. |
get | String | Gets the image's ID. |
get | Positioned | Gets an enum value that represents how the image is laid out. |
get | Number | Gets the image's offset, in points, from the paragraph's left. |
get | Paragraph | Gets theParagraph the image is anchored to. |
get | Number | Gets the image's offset, in points, from the paragraph's top. |
get | Integer | Retrieves the image's width, in pixels. |
set | Positioned | Sets the image's height, in pixels. |
set | Positioned | Sets the definition of how the image is laid out. |
set | Positioned | Sets the image's offset, in points, from the paragraph's left. |
set | Positioned | Sets the image's offset, in points, from the paragraph's top. |
set | Positioned | 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. Thismethod adds the appropriate extension to the filename—for example, "myfile.pdf". However, itassumes that the part of the filename that follows the last period (if any) is an existingextension that should be replaced. Consequently, "ShoppingList.12.25.2014" becomes"ShoppingList.12.25.pdf".
To view the daily quotas for conversions, seeQuotas for GoogleServices. Newly created Google Workspace domains might be temporarily subject to stricterquotas.
Parameters
| Name | Type | Description |
|---|---|---|
content | 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()
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 followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
getId()
Gets the image's ID.
Return
String — the image ID
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
getLayout()
Gets an enum value that represents how the image is laid out.
Return
Positioned — the image layout
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
getLeftOffset()
Gets the image's offset, in points, from the paragraph's left.
Return
Number — the image offset from the left paragraph's left
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
getParagraph()
getTopOffset()
Gets the image's offset, in points, from the paragraph's top.
Return
Number — the image offset from the left paragraph's top
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
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 followingscopes:
https://www.googleapis.com/auth/documents.currentonlyhttps://www.googleapis.com/auth/documents
setHeight(height)
Sets the image's height, in pixels.
Parameters
| Name | Type | Description |
|---|---|---|
height | Integer | the image's height, in pixels |
Return
Positioned — 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
setLayout(layout)
Sets the definition of how the image is laid out.
Parameters
| Name | Type | Description |
|---|---|---|
layout | Positioned | an enum representing the layout mode |
Return
Positioned — this object for chaining
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
setLeftOffset(offset)
Sets the image's offset, in points, from the paragraph's left.
Parameters
| Name | Type | Description |
|---|---|---|
offset | Number | offset from the paragraph's left |
Return
Positioned — this object for chaining
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
setTopOffset(offset)
Sets the image's offset, in points, from the paragraph's top.
Parameters
| Name | Type | Description |
|---|---|---|
offset | Number | offset from the paragraph's top |
Return
Positioned — this object for chaining
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
setWidth(width)
Sets the image's width, in pixels.
Parameters
| Name | Type | Description |
|---|---|---|
width | Integer | the image's width, in pixels |
Return
Positioned — 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
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.