Document Service

  • The Google Apps Script Document service allows programmatic creation, access, and modification of Google Docs files.

  • DocumentApp is the main class for creating and opening documents, while theDocument class manages the document as a whole.

  • The service provides numerous classes to represent document elements, such asBody,Paragraph,Table, andText, each with methods for manipulation.

  • Attributes like font size, color, and alignment can be controlled using theAttribute enumeration.

  • TheElement class serves as a base for all document components, offering general methods for accessing properties and navigating the document structure.

Document

This service allows scripts to create, access, and modify Google Docs files.

//OpenadocumentbyID.vardoc=DocumentApp.openById('DOCUMENT_ID');//Createandopenadocument.doc=DocumentApp.create('Document Name');

Classes

NameBrief description
AttributeAn enumeration of the element attributes.
BodyThe content of a tab in a Google Docs document.
BookmarkAn object representing a bookmark.
ContainerElementA generic element that may contain other elements.
DateAn element representing a formatted date
DocumentA document, containing one or moreTab objects, each of which contains rich text andelements such as tables and lists.
DocumentAppThe document service creates and opensDocuments that can be edited.
DocumentTabA document tab, containing rich text and elements such as tables and lists.
ElementA generic element.
ElementTypeAn enumeration of all the element types.
EquationAn element representing a mathematical expression.
EquationFunctionAn element representing a function in a mathematicalEquation.
EquationFunctionArgumentSeparatorAn element representing a function separator in a mathematicalEquation.
EquationSymbolAn element representing a symbol in a mathematicalEquation.
FontFamilyAn enumeration of the supported fonts.
FooterSectionAn element representing a footer section.
FootnoteAn element representing a footnote.
FootnoteSectionAn element representing a footnote section.
GlyphTypeAn enumeration of the supported glyph types.
HeaderSectionAn element representing a header section.
HorizontalAlignmentAn enumeration of the supported horizontal alignment types.
HorizontalRuleAn element representing an horizontal rule.
InlineDrawingAn element representing an embedded drawing.
InlineImageAn element representing an embedded image.
ListItemAn element representing a list item.
NamedRangeARange that has a name and ID to allow later retrieval.
PageBreakAn element representing a page break.
ParagraphAn element representing a paragraph.
ParagraphHeadingAn enumeration of the standard paragraph headings.
PersonAn element representing a link to a person.
PositionA reference to a location in the document tab, relative to a specific element.
PositionedImageFixed position image anchored to aParagraph.
PositionedLayoutAn enumeration that specifies how to lay out aPositionedImage in relation to surroundingtext.
RangeA range of elements in a document.
RangeBuilderA builder used to constructRange objects from document elements.
RangeElementA wrapper around anElement with a possible start and end offset.
RichLinkAn element representing a link to a Google resource, such as a Drive file or a YouTube video.
TabA tab within a Google Docs document.
TabTypeAn enumeration of all the tab types.
TableAn element representing a table.
TableCellAn element representing a table cell.
TableOfContentsAn element containing a table of contents.
TableRowAn element representing a table row.
TextAn element representing a rich text region.
TextAlignmentAn enumeration of the type of text alignments.
UnsupportedElementAn element representing a region that is unknown or cannot be affected by a script, such as apage number.
VerticalAlignmentAn enumeration of the supported vertical alignment types.

Attribute

Properties

PropertyTypeDescription
BACKGROUND_COLOREnumThe background color of an element (Paragraph, Table, etc) or document.
BOLDEnumThe font weight setting, for rich text.
BORDER_COLOREnumThe border color, for table elements.
BORDER_WIDTHEnumThe border width in points, for table elements.
CODEEnumThe code contents, for equation elements.
FONT_FAMILYEnumThe font family setting, for rich text.
FONT_SIZEEnumThe font size setting in points, for rich text.
FOREGROUND_COLOREnumThe foreground color setting, for rich text.
HEADINGEnumThe heading type, for paragraph elements (for example,DocumentApp.ParagraphHeading.HEADING1).
HEIGHTEnumThe height setting, for image elements.
HORIZONTAL_ALIGNMENTEnumThe horizontal alignment, for paragraph elements (for example,DocumentApp.HorizontalAlignment.CENTER).
INDENT_ENDEnumThe end indentation setting in points, for paragraph elements.
INDENT_FIRST_LINEEnumThe first line indentation setting in points, for paragraph elements.
INDENT_STARTEnumThe start indentation setting in points, for paragraph elements.
ITALICEnumThe font style setting, for rich text.
GLYPH_TYPEEnumThe glyph type, for list item elements.
LEFT_TO_RIGHTEnumThe text direction setting, for rich text.
LINE_SPACINGEnumThe line spacing setting as a multiplier, for paragraph elements.
LINK_URLEnumThe link URL, for rich text.
LIST_IDEnumThe ID of the encompassing list, for list item elements.
MARGIN_BOTTOMEnumThe bottom margin setting in points, for paragraph elements.
MARGIN_LEFTEnumThe left margin setting in points, for paragraph elements.
MARGIN_RIGHTEnumThe right margin setting in points, for paragraph elements.
MARGIN_TOPEnumThe top margin setting in points, for paragraph elements.
NESTING_LEVELEnumThe item nesting level, for list item elements.
MINIMUM_HEIGHTEnumThe minimum height setting in points, for table row elements.
PADDING_BOTTOMEnumThe bottom padding setting in points, for table cell elements.
PADDING_LEFTEnumThe left padding setting in points, for table cell elements.
PADDING_RIGHTEnumThe right padding setting in points, for table cell elements.
PADDING_TOPEnumThe top padding setting in points, for table cell elements.
PAGE_HEIGHTEnumThe page height setting in points, for documents.
PAGE_WIDTHEnumThe page width setting in points, for documents.
SPACING_AFTEREnumThe bottom spacing setting in points, for paragraph elements.
SPACING_BEFOREEnumThe top spacing setting in points, for paragraph elements.
STRIKETHROUGHEnumThe strike-through setting, for rich text.
UNDERLINEEnumThe underline setting, for rich text.
VERTICAL_ALIGNMENTEnumThe vertical alignment setting, for table cell elements.
WIDTHEnumThe width setting, for table cell and image elements.

Body

Methods

MethodReturn typeBrief description
appendHorizontalRule()HorizontalRuleCreates and appends a newHorizontalRule.
appendImage(image)InlineImageCreates and appends a newInlineImage from the specified image blob.
appendImage(image)InlineImageAppends the givenInlineImage.
appendListItem(listItem)ListItemAppends the givenListItem.
appendListItem(text)ListItemCreates and appends a newListItem containing the specified text contents.
appendPageBreak()PageBreakCreates and appends a newPageBreak.
appendPageBreak(pageBreak)PageBreakAppends the givenPageBreak.
appendParagraph(paragraph)ParagraphAppends the givenParagraph.
appendParagraph(text)ParagraphCreates and appends a newParagraph containing the specified text contents.
appendTable()TableCreates and appends a newTable.
appendTable(cells)TableAppends a newTable containing aTableCell for each specified string value.
appendTable(table)TableAppends the givenTable.
clear()BodyClears the contents of the element.
copy()BodyReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getHeadingAttributes(paragraphHeading)ObjectRetrieves the set of attributes for the providedParagraphHeading.
getImages()InlineImage[]|nullRetrieves all theInlineImages contained in the section.
getListItems()ListItem[]|nullRetrieves all theListItems contained in the section.
getMarginBottom()Number|nullRetrieves the bottom margin, in points.
getMarginLeft()Number|nullRetrieves the left margin, in points.
getMarginRight()Number|nullRetrieves the right margin.
getMarginTop()Number|nullRetrieves the top margin.
getNumChildren()IntegerRetrieves the number of children.
getPageHeight()Number|nullRetrieves the page height, in points.
getPageWidth()Number|nullRetrieves the page width, in points.
getParagraphs()Paragraph[]|nullRetrieves all theParagraphs contained in the section (includingListItems).
getParent()ContainerElement|nullRetrieves the element's parent element.
getTables()Table[]|nullRetrieves all theTables contained in the section.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a newHorizontalRule at the specified index.
insertImage(childIndex, image)InlineImageCreates and inserts anInlineImage from the specified image blob, at the specifiedindex.
insertImage(childIndex, image)InlineImageInserts the givenInlineImage at the specified index.
insertListItem(childIndex, listItem)ListItemInserts the givenListItem at the specified index.
insertListItem(childIndex, text)ListItemCreates and inserts a newListItem at the specified index, containing the specifiedtext contents.
insertPageBreak(childIndex)PageBreakCreates and inserts a newPageBreak at the specified index.
insertPageBreak(childIndex, pageBreak)PageBreakInserts the givenPageBreak at the specified index.
insertParagraph(childIndex, paragraph)ParagraphInserts the givenParagraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a newParagraph at the specified index, containing the specifiedtext contents.
insertTable(childIndex)TableCreates and inserts a newTable at the specified index.
insertTable(childIndex, cells)TableCreates and inserts a newTable containing the specified cells, at the specified index.
insertTable(childIndex, table)TableInserts the givenTable at the specified index.
removeChild(child)BodyRemoves the specified child element.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)BodySets the element's attributes.
setHeadingAttributes(paragraphHeading, attributes)BodySets the attributes for the providedParagraphHeading.
setMarginBottom(marginBottom)BodySets the bottom margin, in points.
setMarginLeft(marginLeft)BodySets the left margin, in points.
setMarginRight(marginRight)BodySets the right margin, in points.
setMarginTop(marginTop)BodySets the top margin.
setPageHeight(pageHeight)BodySets the page height, in points.
setPageWidth(pageWidth)BodySets the page width, in points.
setText(text)BodySets the contents as plain text.
setTextAlignment(textAlignment)BodySets the text alignment.

Bookmark

Methods

MethodReturn typeBrief description
getId()StringGets the ID of theBookmark.
getPosition()PositionGets thePosition of theBookmark within theDocumentTab.
remove()voidDeletes theBookmark.

ContainerElement

Methods

MethodReturn typeBrief description
asBody()BodyReturns the current element as aBody.
asEquation()EquationReturns the current element as anEquation.
asFooterSection()FooterSectionReturns the current element as aFooterSection.
asFootnoteSection()FootnoteSectionReturns the current element as aFootnoteSection.
asHeaderSection()HeaderSectionReturns the current element as aHeaderSection.
asListItem()ListItemReturns the current element as aListItem.
asParagraph()ParagraphReturns the current element as aParagraph.
asTable()TableReturns the current element as aTable.
asTableCell()TableCellReturns the current element as aTableCell.
asTableOfContents()TableOfContentsReturns the current element as aTableOfContents.
asTableRow()TableRowReturns the current element as aTableRow.
clear()ContainerElementClears the contents of the element.
copy()ContainerElementReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getLinkUrl()String|nullRetrieves the link url.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()ContainerElement|nullMerges the element with the preceding sibling of the same type.
removeFromParent()ContainerElement|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)ContainerElementSets the element's attributes.
setLinkUrl(url)ContainerElementSets the link url.
setTextAlignment(textAlignment)ContainerElementSets the text alignment.

Date

Methods

MethodReturn typeBrief description
copy()DateReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getDisplayText()StringReturns the display value that's rendered in the document.
getLocale()StringReturns the date's locale used for the display value.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getTimestamp()DateReturns the timestamp associated with the date.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()Date|nullMerges the element with the preceding sibling of the same type.
removeFromParent()Date|nullRemoves the element from its parent.
setAttributes(attributes)DateSets the element's attributes.

Document

Methods

MethodReturn typeBrief description
addBookmark(position)BookmarkAdds aBookmark at the givenPosition to the first tab or, for scripts that arebound to a document, the active tab.
addEditor(emailAddress)DocumentAdds the given user to the list of editors for theDocument.
addEditor(user)DocumentAdds the given user to the list of editors for theDocument.
addEditors(emailAddresses)DocumentAdds the given array of users to the list of editors for theDocument.
addFooter()FooterSectionAdds a footer section, if none exists, to the first tab or, for scripts that arebound to a document, the active tab.
addHeader()HeaderSectionAdds a header section, if none exists, to the first tab or, for scripts that arebound to a document, the active tab.
addNamedRange(name, range)NamedRangeAdds aNamedRange, which is aRange that has a name and ID to use forlater retrieval, in the first tab or, for scripts that arebound to a document, the active tab.
addViewer(emailAddress)DocumentAdds the given user to the list of viewers for theDocument.
addViewer(user)DocumentAdds the given user to the list of viewers for theDocument.
addViewers(emailAddresses)DocumentAdds the given array of users to the list of viewers for theDocument.
getActiveTab()TabGets the user's currently activeTab in the document.
getAs(contentType)BlobRetrieves the currentDocument contents as a blob of the specified type.
getBlob()BlobRetrieves the currentDocument contents as a blob.
getBody()BodyRetrieves the first tab'sBody or, for scripts that arebound to a document, the active tab'sDocumentBodySection.
getBookmark(id)Bookmark|nullGets theBookmark with the given ID in the first tab or, for scripts that arebound to a document, the active tab.
getBookmarks()Bookmark[]Gets allBookmark objects in the first tab or, for scripts that arebound to a document, the active tab.
getCursor()Position|nullGets the user's cursor in the active tab.
getEditors()User[]Gets the list of editors for thisDocument.
getFooter()FooterSection|nullRetrieves the first tab's footer section or, for scripts that arebound to a document, the active tab's footersection.
getFootnotes()Footnote[]|nullRetrieves all theFootnote elements in the first tab's body or, for scripts that arebound to a document, the active tab's body.
getHeader()HeaderSection|nullRetrieves the first tab's header section or, for scripts that arebound to a document, the active tab's headersection.
getId()StringRetrieves the document's unique identifier.
getLanguage()StringGets the document's language code.
getName()StringRetrieves the title of the document.
getNamedRangeById(id)NamedRange|nullGets theNamedRange with the given ID in the first tab or, for scripts that arebound to a document, the active tab.
getNamedRanges()NamedRange[]Gets allNamedRange objects in the first tab or, for scripts that arebound to a document, the active tab.
getNamedRanges(name)NamedRange[]Gets allNamedRange objects with the given name in the first tab or, for scripts thatarebound to a document, the active tab.
getSelection()Range|nullGets the user's selection in the active tab.
getSupportedLanguageCodes()String[]Gets all language codes that are supported in Google Docs files.
getTab(tabId)TabGets theTab with the specified ID.
getTabs()Tab[]Gets all unnestedTabs that are part of the document.
getUrl()StringRetrieves the URL to access the current document.
getViewers()User[]Gets the list of viewers and commenters for thisDocument.
newPosition(element, offset)PositionCreates a newPosition, which is a reference to a location in the tab, relative to aspecific element in the first tab or, for scripts that arebound to a document, the active tab.
newRange()RangeBuilderCreates a builder used to constructRange objects from tab elements in thefirst tab or, for scripts that arebound to adocument, the active tab.
removeEditor(emailAddress)DocumentRemoves the given user from the list of editors for theDocument.
removeEditor(user)DocumentRemoves the given user from the list of editors for theDocument.
removeViewer(emailAddress)DocumentRemoves the given user from the list of viewers and commenters for theDocument.
removeViewer(user)DocumentRemoves the given user from the list of viewers and commenters for theDocument.
saveAndClose()voidSaves the currentDocument.
setActiveTab(tabId)voidSets the user's selectedTab in the current document to the tab with the specified ID.
setCursor(position)DocumentSets the user's cursor, given aPosition.
setLanguage(languageCode)DocumentSets the document's language code.
setName(name)DocumentSets the document title.
setSelection(range)DocumentSets the user's selection in the active tab, given aRange.

DocumentApp

Properties

PropertyTypeDescription
AttributeAttributeTheAttribute enumeration.
ElementTypeElementTypeTheElementType enumeration.
FontFamilyFontFamilyTheFontFamily enumeration.
GlyphTypeGlyphTypeTheGlyphType enumeration.
HorizontalAlignmentHorizontalAlignmentTheHorizontalAlignment enumeration.
ParagraphHeadingParagraphHeadingTheParagraphHeading enumeration.
PositionedLayoutPositionedLayoutThePositionedLayout enumeration.
TextAlignmentTextAlignmentTheTextAlignment enumeration.
VerticalAlignmentVerticalAlignmentTheVerticalAlignment enumeration.

Methods

MethodReturn typeBrief description
create(name)DocumentCreates and returns a new document.
getActiveDocument()DocumentReturns the document to which the script iscontainer-bound.
getUi()UiReturns an instance of the document's user-interface environment that allows the script to addfeatures like menus, dialogs, and sidebars.
openById(id)DocumentReturns the document with the specified ID.
openByUrl(url)DocumentOpens and returns the document with the specified URL.

DocumentTab

Methods

MethodReturn typeBrief description
addBookmark(position)BookmarkAdds aBookmark at the givenPosition.
addFooter()FooterSectionAdds a tab footer section, if none exists.
addHeader()HeaderSectionAdds a tab header section, if none exists.
addNamedRange(name, range)NamedRangeAdds aNamedRange, which is aRange that has a name and ID to use forlater retrieval.
getBody()BodyRetrieves the tab'sBody.
getBookmark(id)Bookmark|nullGets theBookmark with the given ID.
getBookmarks()Bookmark[]Gets allBookmark objects in the tab.
getFooter()FooterSection|nullRetrieves the tab's footer section, if one exists.
getFootnotes()Footnote[]|nullRetrieves all theFootnote elements in the tab's body.
getHeader()HeaderSection|nullRetrieves the tab's header section, if one exists.
getNamedRangeById(id)NamedRange|nullGets theNamedRange with the given ID.
getNamedRanges()NamedRange[]Gets allNamedRange objects in the tab.
getNamedRanges(name)NamedRange[]Gets allNamedRange objects in the tab with the given name.
newPosition(element, offset)PositionCreates a newPosition, which is a reference to a location in the tab, relative to aspecific element.
newRange()RangeBuilderCreates a builder used to constructRange objects from tab elements.

Element

Methods

MethodReturn typeBrief description
asBody()BodyReturns the current element as aBody.
asDate()DateReturns the current element as aDate.
asEquation()EquationReturns the current element as anEquation.
asEquationFunction()EquationFunctionReturns the current element as aEquationFunction.
asEquationFunctionArgumentSeparator()EquationFunctionArgumentSeparatorReturns the current element as aEquationFunctionArgumentSeparator.
asEquationSymbol()EquationSymbolReturns the current element as aEquationSymbol.
asFooterSection()FooterSectionReturns the current element as aFooterSection.
asFootnote()FootnoteReturns the current element as aFootnote.
asFootnoteSection()FootnoteSectionReturns the current element as aFootnoteSection.
asHeaderSection()HeaderSectionReturns the current element as aHeaderSection.
asHorizontalRule()HorizontalRuleReturns the current element as aHorizontalRule.
asInlineDrawing()InlineDrawingReturns the current element as aInlineDrawing.
asInlineImage()InlineImageReturns the current element as aInlineImage.
asListItem()ListItemReturns the current element as aListItem.
asPageBreak()PageBreakReturns the current element as aPageBreak.
asParagraph()ParagraphReturns the current element as aParagraph.
asPerson()PersonReturns the current element as aPerson.
asRichLink()RichLinkReturns the current element as aRichLink, for example, a link to a Google Sheets file.
asTable()TableReturns the current element as aTable.
asTableCell()TableCellReturns the current element as aTableCell.
asTableOfContents()TableOfContentsReturns the current element as aTableOfContents.
asTableRow()TableRowReturns the current element as aTableRow.
asText()TextReturns the current element as aText.
copy()ElementReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()Element|nullMerges the element with the preceding sibling of the same type.
removeFromParent()Element|nullRemoves the element from its parent.
setAttributes(attributes)ElementSets the element's attributes.

ElementType

Properties

PropertyTypeDescription
BODY_SECTIONEnumThe type corresponding to theBody element.
COMMENT_SECTIONEnumThe type corresponding to theCommentSection element.
DATEEnumThe type corresponding to theDateelement.
EQUATIONEnumThe type corresponding to theEquation element.
EQUATION_FUNCTIONEnumThe type corresponding to theEquationFunction element.
EQUATION_FUNCTION_ARGUMENT_SEPARATOREnumThe type corresponding to theEquationFunctionArgumentSeparatorelement.
EQUATION_SYMBOLEnumThe type corresponding to theEquationSymbol element.
RICH_LINKEnumThe type corresponding to theRichLink element.
FOOTER_SECTIONEnumThe type corresponding to theFooterSection element.
FOOTNOTEEnumThe type corresponding to theFootnote element.
FOOTNOTE_SECTIONEnumThe type corresponding to theFootnoteSection element.
HEADER_SECTIONEnumThe type corresponding to theHeaderSection element.
HORIZONTAL_RULEEnumThe type corresponding to theHorizontalRule element.
INLINE_DRAWINGEnumThe type corresponding to theInlineDrawing element.
INLINE_IMAGEEnumThe type corresponding to theInlineImage element.
LIST_ITEMEnumThe type corresponding to theListItem element.
PAGE_BREAKEnumThe type corresponding to thePageBreak element.
PARAGRAPHEnumThe type corresponding to theParagraph element.
PERSONEnumThe type corresponding to thePerson element.
TABLEEnumThe type corresponding to theTable element.
TABLE_CELLEnumThe type corresponding to theTableCell element.
TABLE_OF_CONTENTSEnumThe type corresponding to theTableOfContents element.
TABLE_ROWEnumThe type corresponding to theTableRow element.
TEXTEnumThe type corresponding to theTextelement.
UNSUPPORTEDEnumThe type corresponding toUnsupportedElement.

Equation

Methods

MethodReturn typeBrief description
clear()EquationClears the contents of the element.
copy()EquationReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getLinkUrl()String|nullRetrieves the link url.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()Equation|nullMerges the element with the preceding sibling of the same type.
removeFromParent()Equation|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)EquationSets the element's attributes.
setLinkUrl(url)EquationSets the link url.
setTextAlignment(textAlignment)EquationSets the text alignment.

EquationFunction

Methods

MethodReturn typeBrief description
clear()EquationFunctionClears the contents of the element.
copy()EquationFunctionReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getCode()StringRetrieves the code corresponding to the equation function.
getLinkUrl()String|nullRetrieves the link url.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()EquationFunction|nullMerges the element with the preceding sibling of the same type.
removeFromParent()EquationFunction|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)EquationFunctionSets the element's attributes.
setLinkUrl(url)EquationFunctionSets the link url.
setTextAlignment(textAlignment)EquationFunctionSets the text alignment.

EquationFunctionArgumentSeparator

Methods

MethodReturn typeBrief description
copy()EquationFunctionArgumentSeparatorReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()EquationFunctionArgumentSeparator|nullMerges the element with the preceding sibling of the same type.
removeFromParent()EquationFunctionArgumentSeparator|nullRemoves the element from its parent.
setAttributes(attributes)EquationFunctionArgumentSeparatorSets the element's attributes.

EquationSymbol

Methods

MethodReturn typeBrief description
copy()EquationSymbolReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getCode()StringRetrieves the code corresponding to the equation symbol.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()EquationSymbol|nullMerges the element with the preceding sibling of the same type.
removeFromParent()EquationSymbol|nullRemoves the element from its parent.
setAttributes(attributes)EquationSymbolSets the element's attributes.

FontFamily

FooterSection

Methods

MethodReturn typeBrief description
appendHorizontalRule()HorizontalRuleCreates and appends a newHorizontalRule.
appendImage(image)InlineImageCreates and appends a newInlineImage from the specified image blob.
appendImage(image)InlineImageAppends the givenInlineImage.
appendListItem(listItem)ListItemAppends the givenListItem.
appendListItem(text)ListItemCreates and appends a newListItem containing the specified text contents.
appendParagraph(paragraph)ParagraphAppends the givenParagraph.
appendParagraph(text)ParagraphCreates and appends a newParagraph containing the specified text contents.
appendTable()TableCreates and appends a newTable.
appendTable(cells)TableAppends a newTable containing aTableCell for each specified string value.
appendTable(table)TableAppends the givenTable.
clear()FooterSectionClears the contents of the element.
copy()FooterSectionReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getImages()InlineImage[]|nullRetrieves all theInlineImages contained in the section.
getListItems()ListItem[]|nullRetrieves all theListItems contained in the section.
getNumChildren()IntegerRetrieves the number of children.
getParagraphs()Paragraph[]|nullRetrieves all theParagraphs contained in the section (includingListItems).
getParent()ContainerElement|nullRetrieves the element's parent element.
getTables()Table[]|nullRetrieves all theTables contained in the section.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a newHorizontalRule at the specified index.
insertImage(childIndex, image)InlineImageCreates and inserts anInlineImage from the specified image blob, at the specifiedindex.
insertImage(childIndex, image)InlineImageInserts the givenInlineImage at the specified index.
insertListItem(childIndex, listItem)ListItemInserts the givenListItem at the specified index.
insertListItem(childIndex, text)ListItemCreates and inserts a newListItem at the specified index, containing the specifiedtext contents.
insertParagraph(childIndex, paragraph)ParagraphInserts the givenParagraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a newParagraph at the specified index, containing the specifiedtext contents.
insertTable(childIndex)TableCreates and inserts a newTable at the specified index.
insertTable(childIndex, cells)TableCreates and inserts a newTable containing the specified cells, at the specified index.
insertTable(childIndex, table)TableInserts the givenTable at the specified index.
removeChild(child)FooterSectionRemoves the specified child element.
removeFromParent()FooterSection|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)FooterSectionSets the element's attributes.
setText(text)FooterSectionSets the contents as plain text.
setTextAlignment(textAlignment)FooterSectionSets the text alignment.

Footnote

Methods

MethodReturn typeBrief description
copy()FootnoteReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getFootnoteContents()FootnoteSection|nullRetrieves the contents of the footnote element.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
removeFromParent()Footnote|nullRemoves the element from its parent.
setAttributes(attributes)FootnoteSets the element's attributes.

FootnoteSection

Methods

MethodReturn typeBrief description
appendParagraph(paragraph)ParagraphAppends the givenParagraph.
appendParagraph(text)ParagraphCreates and appends a newParagraph containing the specified text contents.
clear()FootnoteSectionClears the contents of the element.
copy()FootnoteSectionReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParagraphs()Paragraph[]|nullRetrieves all theParagraphs contained in the section (includingListItems).
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
insertParagraph(childIndex, paragraph)ParagraphInserts the givenParagraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a newParagraph at the specified index, containing the specifiedtext contents.
removeChild(child)FootnoteSectionRemoves the specified child element.
removeFromParent()FootnoteSection|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)FootnoteSectionSets the element's attributes.
setText(text)FootnoteSectionSets the contents as plain text.
setTextAlignment(textAlignment)FootnoteSectionSets the text alignment.

GlyphType

Properties

PropertyTypeDescription
BULLETEnumThe default bullet, circular and filled.
HOLLOW_BULLETEnumA hollow bullet.
SQUARE_BULLETEnumA square bullet.
NUMBEREnumA number based bullet.
LATIN_UPPEREnumA latin, uppercase bullet.
LATIN_LOWEREnumA latin, lowercase bullet.
ROMAN_UPPEREnumA roman numeral, uppercase bullet.
ROMAN_LOWEREnumA roman numeral, lowercase bullet.

HeaderSection

Methods

MethodReturn typeBrief description
appendHorizontalRule()HorizontalRuleCreates and appends a newHorizontalRule.
appendImage(image)InlineImageCreates and appends a newInlineImage from the specified image blob.
appendImage(image)InlineImageAppends the givenInlineImage.
appendListItem(listItem)ListItemAppends the givenListItem.
appendListItem(text)ListItemCreates and appends a newListItem containing the specified text contents.
appendParagraph(paragraph)ParagraphAppends the givenParagraph.
appendParagraph(text)ParagraphCreates and appends a newParagraph containing the specified text contents.
appendTable()TableCreates and appends a newTable.
appendTable(cells)TableAppends a newTable containing aTableCell for each specified string value.
appendTable(table)TableAppends the givenTable.
clear()HeaderSectionClears the contents of the element.
copy()HeaderSectionReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getImages()InlineImage[]|nullRetrieves all theInlineImages contained in the section.
getListItems()ListItem[]|nullRetrieves all theListItems contained in the section.
getNumChildren()IntegerRetrieves the number of children.
getParagraphs()Paragraph[]|nullRetrieves all theParagraphs contained in the section (includingListItems).
getParent()ContainerElement|nullRetrieves the element's parent element.
getTables()Table[]|nullRetrieves all theTables contained in the section.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a newHorizontalRule at the specified index.
insertImage(childIndex, image)InlineImageCreates and inserts anInlineImage from the specified image blob, at the specifiedindex.
insertImage(childIndex, image)InlineImageInserts the givenInlineImage at the specified index.
insertListItem(childIndex, listItem)ListItemInserts the givenListItem at the specified index.
insertListItem(childIndex, text)ListItemCreates and inserts a newListItem at the specified index, containing the specifiedtext contents.
insertParagraph(childIndex, paragraph)ParagraphInserts the givenParagraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a newParagraph at the specified index, containing the specifiedtext contents.
insertTable(childIndex)TableCreates and inserts a newTable at the specified index.
insertTable(childIndex, cells)TableCreates and inserts a newTable containing the specified cells, at the specified index.
insertTable(childIndex, table)TableInserts the givenTable at the specified index.
removeChild(child)HeaderSectionRemoves the specified child element.
removeFromParent()HeaderSection|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)HeaderSectionSets the element's attributes.
setText(text)HeaderSectionSets the contents as plain text.
setTextAlignment(textAlignment)HeaderSectionSets the text alignment.

HorizontalAlignment

Properties

PropertyTypeDescription
LEFTEnumThe left-alignment option.
CENTEREnumThe center-alignment option.
RIGHTEnumThe right-alignment option.
JUSTIFYEnumThe justify-alignment option.

HorizontalRule

Methods

MethodReturn typeBrief description
copy()HorizontalRuleReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
removeFromParent()HorizontalRule|nullRemoves the element from its parent.
setAttributes(attributes)HorizontalRuleSets the element's attributes.

InlineDrawing

Methods

MethodReturn typeBrief description
copy()InlineDrawingReturns a detached, deep copy of the current element.
getAltDescription()String|nullReturns the drawing's alternate description.
getAltTitle()String|nullReturns the drawing's alternate title.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()InlineDrawing|nullMerges the element with the preceding sibling of the same type.
removeFromParent()InlineDrawing|nullRemoves the element from its parent.
setAltDescription(description)InlineDrawingSets the drawing's alternate description.
setAltTitle(title)InlineDrawingSets the drawing's alternate title.
setAttributes(attributes)InlineDrawingSets the element's attributes.

InlineImage

Methods

MethodReturn typeBrief description
copy()InlineImageReturns a detached, deep copy of the current element.
getAltDescription()String|nullReturns the image's alternate description.
getAltTitle()String|nullReturns the image's alternate title.
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getAttributes()ObjectRetrieves the element's attributes.
getBlob()BlobReturn the data inside this object as a blob.
getHeight()IntegerRetrieves the image's height, in pixels.
getLinkUrl()String|nullRetrieves the link URL.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
getWidth()IntegerRetrieves the image's width, in pixels.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()InlineImage|nullMerges the element with the preceding sibling of the same type.
removeFromParent()InlineImage|nullRemoves the element from its parent.
setAltDescription(description)InlineImageSets the image's alternate description.
setAltTitle(title)InlineImageSets the image's alternate title.
setAttributes(attributes)InlineImageSets the element's attributes.
setHeight(height)InlineImageSets the image's height, in pixels.
setLinkUrl(url)InlineImageSets the link URL.
setWidth(width)InlineImageSets the image's width, in pixels.

ListItem

Methods

MethodReturn typeBrief description
addPositionedImage(image)PositionedImageCreates and inserts a newPositionedImage from the specified image blob.
appendHorizontalRule()HorizontalRuleCreates and appends a newHorizontalRule.
appendInlineImage(image)InlineImageCreates and appends a newInlineImage from the specified image blob.
appendInlineImage(image)InlineImageAppends the givenInlineImage.
appendPageBreak()PageBreakCreates and appends a newPageBreak.
appendPageBreak(pageBreak)PageBreakAppends the givenPageBreak.
appendText(text)TextCreates and appends a newText element with the specified contents.
appendText(text)TextAppends the givenText element.
clear()ListItemClears the contents of the element.
copy()ListItemReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAlignment()HorizontalAlignment|nullRetrieves theHorizontalAlignment.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getGlyphType()GlyphType|nullRetrieves the list item'sGlyphType.
getHeading()ParagraphHeading|nullRetrieves theParagraphHeading.
getIndentEnd()Number|nullRetrieves the end indentation, in points.
getIndentFirstLine()Number|nullRetrieves the first line indentation, in points.
getIndentStart()Number|nullRetrieves the start indentation.
getLineSpacing()Number|nullRetrieves the line spacing, in points.
getLinkUrl()String|nullRetrieves the link url.
getListId()String|nullRetrieves the list ID.
getNestingLevel()IntegerRetrieves the list item's nesting level.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPositionedImage(id)PositionedImageGets aPositionedImage by the image's ID.
getPositionedImages()PositionedImage[]Gets allPositionedImage objects anchored to the paragraph.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getSpacingAfter()Number|nullRetrieves the spacing after the element, in points.
getSpacingBefore()Number|nullRetrieves the spacing before the element, in points.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts aHorizontalRule at the specified index.
insertInlineImage(childIndex, image)InlineImageCreates and inserts a newInlineImage from the specified image blob, at the specifiedindex.
insertInlineImage(childIndex, image)InlineImageInserts the givenInlineImage at the specified index.
insertPageBreak(childIndex)PageBreakCreates and inserts a newPageBreak at the specified index.
insertPageBreak(childIndex, pageBreak)PageBreakInserts the givenPageBreak at the specified index.
insertText(childIndex, text)TextCreates and inserts a new text element at the specified index.
insertText(childIndex, text)TextInserts the givenText element at the specified index, with the specified textcontents.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
isLeftToRight()Boolean|nullRetrieves the left-to-right setting.
merge()ListItem|nullMerges the element with the preceding sibling of the same type.
removeChild(child)ListItemRemoves the specified child element.
removeFromParent()ListItem|nullRemoves the element from its parent.
removePositionedImage(id)BooleanRemoves aPositionedImage by the image's ID.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAlignment(alignment)ListItemSets theHorizontalAlignment.
setAttributes(attributes)ListItemSets the element's attributes.
setGlyphType(glyphType)ListItemSets the list item'sGlyphType.
setHeading(heading)ListItemSets theParagraphHeading.
setIndentEnd(indentEnd)ListItemSets the end indentation, in points.
setIndentFirstLine(indentFirstLine)ListItemSets the first line indentation, in points.
setIndentStart(indentStart)ListItemSets the start indentation, in points.
setLeftToRight(leftToRight)ListItemSets the left-to-right setting.
setLineSpacing(multiplier)ListItemSets the line spacing, as a quantity indicating the number of lines to use for spacing.
setLinkUrl(url)ListItemSets the link url.
setListId(listItem)ListItemSets the list ID.
setNestingLevel(nestingLevel)ListItemSets the list item's nesting level.
setSpacingAfter(spacingAfter)ListItemSets the spacing after the element, in points.
setSpacingBefore(spacingBefore)ListItemSets the spacing before the element, in points.
setText(text)voidSets the contents of the list item as text.
setTextAlignment(textAlignment)ListItemSets the text alignment.

NamedRange

Methods

MethodReturn typeBrief description
getId()StringGets the ID of thisNamedRange.
getName()StringGets the name of thisNamedRange.
getRange()RangeGets the range of elements associated with thisNamedRange.
remove()voidRemoves thisNamedRange from the tab.

PageBreak

Methods

MethodReturn typeBrief description
copy()PageBreakReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
removeFromParent()PageBreak|nullRemoves the element from its parent.
setAttributes(attributes)PageBreakSets the element's attributes.

Paragraph

Methods

MethodReturn typeBrief description
addPositionedImage(image)PositionedImageCreates and inserts a newPositionedImage from the specified image blob.
appendHorizontalRule()HorizontalRuleCreates and appends a newHorizontalRule.
appendInlineImage(image)InlineImageCreates and appends a newInlineImage from the specified image blob.
appendInlineImage(image)InlineImageAppends the givenInlineImage.
appendPageBreak()PageBreakCreates and appends a newPageBreak.
appendPageBreak(pageBreak)PageBreakAppends the givenPageBreak.
appendText(text)TextCreates and appends a newText element with the specified contents.
appendText(text)TextAppends the givenText element.
clear()ParagraphClears the contents of the element.
copy()ParagraphReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAlignment()HorizontalAlignment|nullRetrieves theHorizontalAlignment.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getHeading()ParagraphHeading|nullRetrieves theParagraphHeading.
getIndentEnd()Number|nullRetrieves the end indentation, in points.
getIndentFirstLine()Number|nullRetrieves the first line indentation, in points.
getIndentStart()Number|nullRetrieves the start indentation.
getLineSpacing()Number|nullRetrieves the line spacing, in points.
getLinkUrl()String|nullRetrieves the link url.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPositionedImage(id)PositionedImageGets aPositionedImage by the image's ID.
getPositionedImages()PositionedImage[]Gets allPositionedImage objects anchored to the paragraph.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getSpacingAfter()Number|nullRetrieves the spacing after the element, in points.
getSpacingBefore()Number|nullRetrieves the spacing before the element, in points.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts aHorizontalRule at the specified index.
insertInlineImage(childIndex, image)InlineImageCreates and inserts a newInlineImage from the specified image blob, at the specifiedindex.
insertInlineImage(childIndex, image)InlineImageInserts the givenInlineImage at the specified index.
insertPageBreak(childIndex)PageBreakCreates and inserts a newPageBreak at the specified index.
insertPageBreak(childIndex, pageBreak)PageBreakInserts the givenPageBreak at the specified index.
insertText(childIndex, text)TextCreates and inserts a new text element at the specified index.
insertText(childIndex, text)TextInserts the givenText element at the specified index, with the specified textcontents.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
isLeftToRight()Boolean|nullRetrieves the left-to-right setting.
merge()Paragraph|nullMerges the element with the preceding sibling of the same type.
removeChild(child)ParagraphRemoves the specified child element.
removeFromParent()Paragraph|nullRemoves the element from its parent.
removePositionedImage(id)BooleanRemoves aPositionedImage by the image's ID.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAlignment(alignment)ParagraphSets theHorizontalAlignment.
setAttributes(attributes)ParagraphSets the element's attributes.
setHeading(heading)ParagraphSets theParagraphHeading.
setIndentEnd(indentEnd)ParagraphSets the end indentation, in points.
setIndentFirstLine(indentFirstLine)ParagraphSets the first line indentation, in points.
setIndentStart(indentStart)ParagraphSets the start indentation, in points.
setLeftToRight(leftToRight)ParagraphSets the left-to-right setting.
setLineSpacing(multiplier)ParagraphSets the line spacing, as a quantity indicating the number of lines to use for spacing.
setLinkUrl(url)ParagraphSets the link url.
setSpacingAfter(spacingAfter)ParagraphSets the spacing after the element, in points.
setSpacingBefore(spacingBefore)ParagraphSets the spacing before the element, in points.
setText(text)voidSets the contents of the paragraph as text.
setTextAlignment(textAlignment)ParagraphSets the text alignment.

ParagraphHeading

Properties

PropertyTypeDescription
NORMALEnumThe heading option for normal text.
HEADING1EnumThe highest heading option.
HEADING2EnumThe second heading option.
HEADING3EnumThe third heading option
HEADING4EnumThe fourth heading option.
HEADING5EnumThe fifth heading option.
HEADING6EnumThe lowest heading option.
TITLEEnumThe title heading option.
SUBTITLEEnumThe subtitle heading option.

Person

Methods

MethodReturn typeBrief description
copy()PersonReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getEmail()StringReturns the person's email address.
getName()String|nullReturns the person's display name, if set.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()Person|nullMerges the element with the preceding sibling of the same type.
removeFromParent()Person|nullRemoves the element from its parent.
setAttributes(attributes)PersonSets the element's attributes.

Position

Methods

MethodReturn typeBrief description
getElement()ElementGets the element that contains thisPosition.
getOffset()IntegerGets thisPosition's relative location within the element that contains it.
getSurroundingText()TextCreates an artificialText element that represents the text and formatting of theParagraph orListItem that contains thePosition, either directly or through a chain of child elements.
getSurroundingTextOffset()IntegerGets the offset of thisPosition within theText element returned bygetSurroundingText().
insertBookmark()BookmarkCreates and inserts a newBookmark at thisPosition.
insertInlineImage(image)InlineImage|nullCreates and inserts a newInlineImage at thisPosition from the specified imageblob.
insertText(text)Text|nullInserts the specified text at thisPosition.

PositionedImage

Methods

MethodReturn typeBrief description
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getBlob()BlobReturn the data inside this object as a blob.
getHeight()IntegerRetrieves the image's height, in pixels.
getId()StringGets the image's ID.
getLayout()PositionedLayoutGets an enum value that represents how the image is laid out.
getLeftOffset()NumberGets the image's offset, in points, from the paragraph's left.
getParagraph()ParagraphGets theParagraph the image is anchored to.
getTopOffset()NumberGets the image's offset, in points, from the paragraph's top.
getWidth()IntegerRetrieves the image's width, in pixels.
setHeight(height)PositionedImageSets the image's height, in pixels.
setLayout(layout)PositionedImageSets the definition of how the image is laid out.
setLeftOffset(offset)PositionedImageSets the image's offset, in points, from the paragraph's left.
setTopOffset(offset)PositionedImageSets the image's offset, in points, from the paragraph's top.
setWidth(width)PositionedImageSets the image's width, in pixels.

PositionedLayout

Properties

PropertyTypeDescription
ABOVE_TEXTEnumThe image is positioned above the text.
BREAK_BOTHEnumThe image breaks the text on the left and right.
BREAK_LEFTEnumThe image breaks the text on the left.
BREAK_RIGHTEnumThe image breaks the text on the right.
WRAP_TEXTEnumThe image is wrapped by text.

Range

Methods

MethodReturn typeBrief description
getRangeElements()RangeElement[]Gets all elements in thisRange, including any partialText elements (for example, in the caseof a selection that includes only part of aText element).

RangeBuilder

Methods

MethodReturn typeBrief description
addElement(element)RangeBuilderAdds an entireElement to thisRangeBuilder.
addElement(textElement, startOffset, endOffsetInclusive)RangeBuilderAdds a partialText element to thisRangeBuilder.
addElementsBetween(startElement, endElementInclusive)RangeBuilderAdds two entire elements, and all elements between them, to thisRangeBuilder.
addElementsBetween(startTextElement, startOffset, endTextElementInclusive, endOffsetInclusive)RangeBuilderAdds two partialText elements, and all elements between them, to theRangeBuilder.
addRange(range)RangeBuilderAdds the contents of anotherRange to thisRangeBuilder.
build()RangeConstructs aRange from the settings applied to the builder.
getRangeElements()RangeElement[]Gets all elements in thisRange, including any partialText elements (for example, in the caseof a selection that includes only part of aText element).

RangeElement

Methods

MethodReturn typeBrief description
getElement()ElementGets theElement that corresponds to thisRangeElement.
getEndOffsetInclusive()IntegerGets the position of the end of a partial range within the range element.
getStartOffset()IntegerGets the position of the start of a partial range within the range element.
isPartial()BooleanDetermines whether this range element covers the entire element or a partial selection of theelement's characters.

RichLink

Methods

MethodReturn typeBrief description
copy()RichLinkReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getMimeType()String|nullReturns theMIME type ofthe link, which is available when the item is a link to a Drive file andnullotherwise.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getTitle()StringReturns the link's displayed title.
getType()ElementTypeRetrieves the element'sElementType.
getUrl()StringReturns the URL of the resource.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()RichLink|nullMerges the element with the preceding sibling of the same type.
removeFromParent()RichLink|nullRemoves the element from its parent.
setAttributes(attributes)RichLinkSets the element's attributes.

Tab

Methods

MethodReturn typeBrief description
asDocumentTab()DocumentTabRetrieves the tab contents as aDocumentTab.
getChildTabs()Tab[]Retrieves the child tabs nested within this tab.
getId()StringRetrieves the ID of the tab.
getIndex()IntegerRetrieves the 0-based index of the tab within the parent.
getTitle()StringRetrieves the title of the tab.
getType()TabTypeRetrieves the type of tab.

TabType

Properties

PropertyTypeDescription
DOCUMENT_TABEnumThe type corresponding toDocumentTab.

Table

Methods

MethodReturn typeBrief description
appendTableRow()TableRowCreates and appends a newTableRow.
appendTableRow(tableRow)TableRowAppends the givenTableRow.
clear()TableClears the contents of the element.
copy()TableReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getBorderColor()String|nullRetrieves the border color.
getBorderWidth()Number|nullRetrieves the border width, in points.
getCell(rowIndex, cellIndex)TableCell|nullRetrieves theTableCell at the specified row and cell indices.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getColumnWidth(columnIndex)Number|nullRetrieves the width of the specified table column, in points.
getLinkUrl()String|nullRetrieves the link url.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getNumRows()IntegerRetrieves the number ofTableRows.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getRow(rowIndex)TableRow|nullRetrieves theTableRow at the specified row index.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
insertTableRow(childIndex)TableRowCreates and inserts a newTableRow at the specified index.
insertTableRow(childIndex, tableRow)TableRowInserts the givenTableRow at the specified index.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
removeChild(child)TableRemoves the specified child element.
removeFromParent()Table|nullRemoves the element from its parent.
removeRow(rowIndex)TableRowRemoves theTableRow at the specified row index.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)TableSets the element's attributes.
setBorderColor(color)TableSets the border color.
setBorderWidth(width)TableSets the border width, in points.
setColumnWidth(columnIndex, width)TableSets the width of the specified column, in points.
setLinkUrl(url)TableSets the link url.
setTextAlignment(textAlignment)TableSets the text alignment.

TableCell

Methods

MethodReturn typeBrief description
appendHorizontalRule()HorizontalRuleCreates and appends a newHorizontalRule.
appendImage(image)InlineImageCreates and appends a newInlineImage from the specified image blob.
appendImage(image)InlineImageAppends the givenInlineImage.
appendListItem(listItem)ListItemAppends the givenListItem.
appendListItem(text)ListItemCreates and appends a newListItem.
appendParagraph(paragraph)ParagraphAppends the givenParagraph.
appendParagraph(text)ParagraphCreates and appends a newParagraph.
appendTable()TableCreates and appends a newTable.
appendTable(cells)TableAppends a newTable containing the specified cells.
appendTable(table)TableAppends the givenTable.
clear()TableCellClears the contents of the element.
copy()TableCellReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getBackgroundColor()String|nullRetrieves the background color.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getColSpan()IntegerRetrieves the column span, which is the number of columns of table cells this cell spans.
getLinkUrl()String|nullRetrieves the link url.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getPaddingBottom()Number|nullRetrieves the bottom padding, in points.
getPaddingLeft()Number|nullRetrieves the left padding, in points.
getPaddingRight()Number|nullRetrieves the right padding, in points.
getPaddingTop()Number|nullRetrieves the top padding, in points.
getParent()ContainerElement|nullRetrieves the element's parent element.
getParentRow()TableRow|nullRetrieves theTableRow containing the currentTableCell.
getParentTable()Table|nullRetrieves theTable containing the currentTableCell.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getRowSpan()IntegerRetrieves the row span, which is the number of rows of table cells this cell spans.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
getVerticalAlignment()VerticalAlignment|nullRetrieves theVerticalAlignment.
getWidth()Number|nullRetrieves the width of the column containing the cell, in points.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a newHorizontalRule at the specified index.
insertImage(childIndex, image)InlineImageCreates and inserts anInlineImage from the specified image blob, at the specifiedindex.
insertImage(childIndex, image)InlineImageInserts the givenInlineImage at the specified index.
insertListItem(childIndex, listItem)ListItemInserts the givenListItem at the specified index.
insertListItem(childIndex, text)ListItemCreates and inserts a newListItem at the specified index.
insertParagraph(childIndex, paragraph)ParagraphInserts the givenParagraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a newParagraph at the specified index.
insertTable(childIndex)TableCreates and inserts a newTable at the specified index.
insertTable(childIndex, cells)TableCreates and inserts a newTable containing the specified cells, at the specified index.
insertTable(childIndex, table)TableInserts the givenTable at the specified index.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()TableCell|nullMerges the element with the preceding sibling of the same type.
removeChild(child)TableCellRemoves the specified child element.
removeFromParent()TableCell|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)TableCellSets the element's attributes.
setBackgroundColor(color)TableCellSets the background color.
setLinkUrl(url)TableCellSets the link url.
setPaddingBottom(paddingBottom)TableCellSets the bottom padding, in points.
setPaddingLeft(paddingLeft)TableCellSets the left padding, in points.
setPaddingRight(paddingRight)TableCellSets the right padding, in points.
setPaddingTop(paddingTop)TableCellSets the top padding, in points.
setText(text)TableCellSets the contents as plain text.
setTextAlignment(textAlignment)TableCellSets the text alignment.
setVerticalAlignment(alignment)TableCellSets the vertical alignment.
setWidth(width)TableCellSets the width of the column containing the current cell, in points.

TableOfContents

Methods

MethodReturn typeBrief description
clear()TableOfContentsClears the contents of the element.
copy()TableOfContentsReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getLinkUrl()String|nullRetrieves the link url.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
removeFromParent()TableOfContents|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)TableOfContentsSets the element's attributes.
setLinkUrl(url)TableOfContentsSets the link url.
setTextAlignment(textAlignment)TableOfContentsSets the text alignment.

TableRow

Methods

MethodReturn typeBrief description
appendTableCell()TableCellCreates and appends a newTableCell.
appendTableCell(textContents)TableCellAppends the givenTableCell containing the specified text.
appendTableCell(tableCell)TableCellAppends the givenTableCell.
clear()TableRowClears the contents of the element.
copy()TableRowReturns a detached, deep copy of the current element.
editAsText()TextObtains aText version of the current element, for editing.
findElement(elementType)RangeElement|nullSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElement|nullSearches the contents of the element for a descendant of the specified type, starting from thespecifiedRangeElement.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getCell(cellIndex)TableCell|nullRetrieves theTableCell at the specified cell index.
getChild(childIndex)ElementRetrieves the child element at the specified child index.
getChildIndex(child)IntegerRetrieves the child index for the specified child element.
getLinkUrl()String|nullRetrieves the link url.
getMinimumHeight()Number|nullRetrieves the minimum height, in points.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getNumCells()IntegerRetrieves the number of cells in the row.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElement|nullRetrieves the element's parent element.
getParentTable()Table|nullRetrieves theTable containing the current row.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getType()ElementTypeRetrieves the element'sElementType.
insertTableCell(childIndex)TableCellCreates and inserts a newTableCell at the specified index.
insertTableCell(childIndex, textContents)TableCellInserts the givenTableCell at the specified index, containing the given text.
insertTableCell(childIndex, tableCell)TableCellInserts the givenTableCell at the specified index.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()TableRow|nullMerges the element with the preceding sibling of the same type.
removeCell(cellIndex)TableCellRemoves theTableCell at the specified cell index.
removeChild(child)TableRowRemoves the specified child element.
removeFromParent()TableRow|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(attributes)TableRowSets the element's attributes.
setLinkUrl(url)TableRowSets the link url.
setMinimumHeight(minHeight)TableRowSets the minimum height, in points.
setTextAlignment(textAlignment)TableRowSets the text alignment.

Text

Methods

MethodReturn typeBrief description
appendText(text)TextAdds the specified text to the end of this text region.
copy()TextReturns a detached, deep copy of the current element.
deleteText(startOffset, endOffsetInclusive)TextDeletes a range of text.
editAsText()TextObtains aText version of the current element, for editing.
findText(searchPattern)RangeElement|nullSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElement|nullSearches the contents of the element for the specified text pattern, starting from a givensearch result.
getAttributes()ObjectRetrieves the element's attributes.
getAttributes(offset)ObjectRetrieves the attributes at the specified character offset.
getBackgroundColor()String|nullRetrieves the background color setting.
getBackgroundColor(offset)String|nullRetrieves the background color at the specified character offset.
getFontFamily()String|nullRetrieves the font family setting.
getFontFamily(offset)String|nullRetrieves the font family at the specified character offset.
getFontSize()Number|nullRetrieves the font size setting.
getFontSize(offset)Number|nullRetrieves the font size at the specified character offset.
getForegroundColor()String|nullRetrieves the foreground color setting.
getForegroundColor(offset)String|nullRetrieves the foreground color at the specified character offset.
getLinkUrl()String|nullRetrieves the link url.
getLinkUrl(offset)String|nullRetrieves the link URL at the specified character offset.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignment|nullGets the text alignment.
getTextAlignment(offset)TextAlignment|nullGets the text alignment for a single character.
getTextAttributeIndices()Integer[]Retrieves the set of text indices that correspond to the start of distinct text formattingruns.
getType()ElementTypeRetrieves the element'sElementType.
insertText(offset, text)TextInserts the specified text at the given character offset.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
isBold()Boolean|nullRetrieves the bold setting.
isBold(offset)Boolean|nullRetrieves the bold setting at the specified character offset.
isItalic()Boolean|nullRetrieves the italic setting.
isItalic(offset)Boolean|nullRetrieves the italic setting at the specified character offset.
isStrikethrough()Boolean|nullRetrieves the strikethrough setting.
isStrikethrough(offset)Boolean|nullRetrieves the strikethrough setting at the specified character offset.
isUnderline()Boolean|nullRetrieves the underline setting.
isUnderline(offset)Boolean|nullRetrieves the underline setting at the specified character offset.
merge()Text|nullMerges the element with the preceding sibling of the same type.
removeFromParent()Text|nullRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regularexpressions.
setAttributes(startOffset, endOffsetInclusive, attributes)TextApplies the specified attributes to the given character range.
setAttributes(attributes)TextSets the element's attributes.
setBackgroundColor(startOffset, endOffsetInclusive, color)TextSets the background color for the specified character range.
setBackgroundColor(color)TextSets the background color.
setBold(bold)TextSets the bold setting.
setBold(startOffset, endOffsetInclusive, bold)TextSets the bold setting for the specified character range.
setFontFamily(startOffset, endOffsetInclusive, fontFamilyName)TextSets the font family for the specified character range.
setFontFamily(fontFamilyName)TextSets the font family.
setFontSize(startOffset, endOffsetInclusive, size)TextSets the font size for the specified character range.
setFontSize(size)TextSets the font size.
setForegroundColor(startOffset, endOffsetInclusive, color)TextSets the foreground color for the specified character range.
setForegroundColor(color)TextSets the foreground color.
setItalic(italic)TextSets the italic setting.
setItalic(startOffset, endOffsetInclusive, italic)TextSets the italic setting for the specified character range.
setLinkUrl(startOffset, endOffsetInclusive, url)TextSets the link URL for the specified character range.
setLinkUrl(url)TextSets the link url.
setStrikethrough(strikethrough)TextSets the strikethrough setting.
setStrikethrough(startOffset, endOffsetInclusive, strikethrough)TextSets the strikethrough setting for the specified character range.
setText(text)TextSets the text contents.
setTextAlignment(startOffset, endOffsetInclusive, textAlignment)TextSets the text alignment for a given character range.
setTextAlignment(textAlignment)TextSets the text alignment.
setUnderline(underline)TextSets the underline setting.
setUnderline(startOffset, endOffsetInclusive, underline)TextSets the underline setting for the specified character range.

TextAlignment

Properties

PropertyTypeDescription
NORMALEnumThe normal text alignment.
SUPERSCRIPTEnumThe superscript text alignment.
SUBSCRIPTEnumThe subscript text alignment.

UnsupportedElement

Methods

MethodReturn typeBrief description
copy()UnsupportedElementReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()Element|nullRetrieves the element's next sibling element.
getParent()ContainerElement|nullRetrieves the element's parent element.
getPreviousSibling()Element|nullRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element'sElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of theDocument.
merge()UnsupportedElement|nullMerges the element with the preceding sibling of the same type.
removeFromParent()UnsupportedElement|nullRemoves the element from its parent.
setAttributes(attributes)UnsupportedElementSets the element's attributes.

VerticalAlignment

Properties

PropertyTypeDescription
BOTTOMEnumThe bottom-alignment option.
CENTEREnumThe center-alignment option.
TOPEnumThe top-alignment option.

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.