Document Service

Document

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

// Open a document by ID.
var doc = DocumentApp.openById('DOCUMENT_ID_GOES_HERE');

// Create and open a document.
doc = DocumentApp.create('Document Name');

Classes

NameBrief description
AttributeAn enumeration of the element attributes.
BodyAn element representing a document body.
BookmarkAn object representing a bookmark.
ContainerElementA generic element that may contain other elements.
DateAn element representing a formatted date
DocumentA document, containing rich text and elements such as tables and lists.
DocumentAppThe document service creates and opens Documents that can be edited.
ElementA generic element.
ElementTypeAn enumeration of all the element types.
EquationAn element representing a mathematical expression.
EquationFunctionAn element representing a function in a mathematical Equation.
EquationFunctionArgumentSeparatorAn element representing a function separator in a mathematical Equation.
EquationSymbolAn element representing a symbol in a mathematical Equation.
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.
NamedRangeA Range 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, relative to a specific element.
PositionedImageFixed position image anchored to a Paragraph.
PositionedLayoutAn enumeration that specifies how to lay out a PositionedImage in relation to surrounding text.
RangeA range of elements in a document.
RangeBuilderA builder used to construct Range objects from document elements.
RangeElementA wrapper around an Element 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.
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 a page 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 new HorizontalRule.
appendImage(image)InlineImageCreates and appends a new InlineImage from the specified image blob.
appendImage(image)InlineImageAppends the given InlineImage.
appendListItem(listItem)ListItemAppends the given ListItem.
appendListItem(text)ListItemCreates and appends a new ListItem containing the specified text contents.
appendPageBreak()PageBreakCreates and appends a new PageBreak.
appendPageBreak(pageBreak)PageBreakAppends the given PageBreak.
appendParagraph(paragraph)ParagraphAppends the given Paragraph.
appendParagraph(text)ParagraphCreates and appends a new Paragraph containing the specified text contents.
appendTable()TableCreates and appends a new Table.
appendTable(cells)TableAppends a new Table containing a TableCell for each specified string value.
appendTable(table)TableAppends the given Table.
clear()BodyClears the contents of the element.
copy()BodyReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search 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 provided ParagraphHeading.
getImages()InlineImage[]Retrieves all the InlineImages contained in the section.
getListItems()ListItem[]Retrieves all the ListItems contained in the section.
getMarginBottom()NumberRetrieves the bottom margin, in points.
getMarginLeft()NumberRetrieves the left margin, in points.
getMarginRight()NumberRetrieves the right margin.
getMarginTop()NumberRetrieves the top margin.
getNumChildren()IntegerRetrieves the number of children.
getPageHeight()NumberRetrieves the page height, in points.
getPageWidth()NumberRetrieves the page width, in points.
getParagraphs()Paragraph[]Retrieves all the Paragraphs contained in the section (including ListItems).
getParent()ContainerElementRetrieves the element's parent element.
getTables()Table[]Retrieves all the Tables contained in the section.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a new HorizontalRule at the specified index.
insertImage(childIndex, image)InlineImageCreates and inserts an InlineImage from the specified image blob, at the specified index.
insertImage(childIndex, image)InlineImageInserts the given InlineImage at the specified index.
insertListItem(childIndex, listItem)ListItemInserts the given ListItem at the specified index.
insertListItem(childIndex, text)ListItemCreates and inserts a new ListItem at the specified index, containing the specified text contents.
insertPageBreak(childIndex)PageBreakCreates and inserts a new PageBreak at the specified index.
insertPageBreak(childIndex, pageBreak)PageBreakInserts the given PageBreak at the specified index.
insertParagraph(childIndex, paragraph)ParagraphInserts the given Paragraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a new Paragraph at the specified index, containing the specified text contents.
insertTable(childIndex)TableCreates and inserts a new Table at the specified index.
insertTable(childIndex, cells)TableCreates and inserts a new Table containing the specified cells, at the specified index.
insertTable(childIndex, table)TableInserts the given Table 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 regular expressions.
setAttributes(attributes)BodySets the element's attributes.
setHeadingAttributes(paragraphHeading, attributes)BodySets the attributes for the provided ParagraphHeading.
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 the Bookmark.
getPosition()PositionGets the Position of the Bookmark within the Document.
remove()voidDeletes the Bookmark.

ContainerElement

Methods

MethodReturn typeBrief description
asBody()BodyReturns the current element as a Body.
asEquation()EquationReturns the current element as an Equation.
asFooterSection()FooterSectionReturns the current element as a FooterSection.
asFootnoteSection()FootnoteSectionReturns the current element as a FootnoteSection.
asHeaderSection()HeaderSectionReturns the current element as a HeaderSection.
asListItem()ListItemReturns the current element as a ListItem.
asParagraph()ParagraphReturns the current element as a Paragraph.
asTable()TableReturns the current element as a Table.
asTableCell()TableCellReturns the current element as a TableCell.
asTableOfContents()TableOfContentsReturns the current element as a TableOfContents.
asTableRow()TableRowReturns the current element as a TableRow.
clear()ContainerElementClears the contents of the element.
copy()ContainerElementReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search 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()StringRetrieves the link url.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()ContainerElementMerges the element with the preceding sibling of the same type.
removeFromParent()ContainerElementRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getTimestamp()DateReturns the timestamp associated with the date.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()DateMerges the element with the preceding sibling of the same type.
removeFromParent()DateRemoves the element from its parent.
setAttributes(attributes)DateSets the element's attributes.

Document

Methods

MethodReturn typeBrief description
addBookmark(position)BookmarkAdds a Bookmark at the given Position.
addEditor(emailAddress)DocumentAdds the given user to the list of editors for the Document.
addEditor(user)DocumentAdds the given user to the list of editors for the Document.
addEditors(emailAddresses)DocumentAdds the given array of users to the list of editors for the Document.
addFooter()FooterSectionAdds a document footer section, if none exists.
addHeader()HeaderSectionAdds a document header section, if none exists.
addNamedRange(name, range)NamedRangeAdds a NamedRange, which is a Range that has a name and ID to use for later retrieval.
addViewer(emailAddress)DocumentAdds the given user to the list of viewers for the Document.
addViewer(user)DocumentAdds the given user to the list of viewers for the Document.
addViewers(emailAddresses)DocumentAdds the given array of users to the list of viewers for the Document.
getAs(contentType)BlobRetrieves the current Document contents as a blob of the specified type.
getBlob()BlobRetrieves the current Document contents as a blob.
getBody()BodyRetrieves the active document's Body.
getBookmark(id)BookmarkGets the Bookmark with the given ID.
getBookmarks()Bookmark[]Gets all Bookmark objects in the document.
getCursor()PositionGets the user's cursor in the active document.
getEditors()User[]Gets the list of editors for this Document.
getFooter()FooterSectionRetrieves the document's footer section, if one exists.
getFootnotes()Footnote[]Retrieves all the Footnote elements in the document body.
getHeader()HeaderSectionRetrieves the document's header section, if one exists.
getId()StringRetrieves the document's unique identifier.
getLanguage()StringGets the document's language code.
getName()StringRetrieves the title of the document.
getNamedRangeById(id)NamedRangeGets the NamedRange with the given ID.
getNamedRanges()NamedRange[]Gets all NamedRange objects in the document.
getNamedRanges(name)NamedRange[]Gets all NamedRange objects in the document with the given name.
getSelection()RangeGets the user's selection in the active document.
getSupportedLanguageCodes()String[]Gets all language codes that are supported in Google Docs files.
getUrl()StringRetrieves the URL to access the current document.
getViewers()User[]Gets the list of viewers and commenters for this Document.
newPosition(element, offset)PositionCreates a new Position, which is a reference to a location in the document, relative to a specific element.
newRange()RangeBuilderCreates a builder used to construct Range objects from document elements.
removeEditor(emailAddress)DocumentRemoves the given user from the list of editors for the Document.
removeEditor(user)DocumentRemoves the given user from the list of editors for the Document.
removeViewer(emailAddress)DocumentRemoves the given user from the list of viewers and commenters for the Document.
removeViewer(user)DocumentRemoves the given user from the list of viewers and commenters for the Document.
saveAndClose()voidSaves the current Document.
setCursor(position)DocumentSets the user's cursor in the active document, given a Position.
setLanguage(languageCode)DocumentSets the document's language code.
setName(name)DocumentSets the document title.
setSelection(range)DocumentSets the user's selection in the active document, given a Range.

DocumentApp

Properties

PropertyTypeDescription
AttributeAttributeThe Attribute enumeration.
ElementTypeElementTypeThe ElementType enumeration.
FontFamilyFontFamilyThe FontFamily enumeration.
GlyphTypeGlyphTypeThe GlyphType enumeration.
HorizontalAlignmentHorizontalAlignmentThe HorizontalAlignment enumeration.
ParagraphHeadingParagraphHeadingThe ParagraphHeading enumeration.
PositionedLayoutPositionedLayoutThe PositionedLayout enumeration.
TextAlignmentTextAlignmentThe TextAlignment enumeration.
VerticalAlignmentVerticalAlignmentThe VerticalAlignment enumeration.

Methods

MethodReturn typeBrief description
create(name)DocumentCreates and returns a new document.
getActiveDocument()DocumentReturns the document to which the script is container-bound.
getUi()UiReturns an instance of the document's user-interface environment that allows the script to add features 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.

Element

Methods

MethodReturn typeBrief description
asBody()BodyReturns the current element as a Body.
asDate()DateReturns the current element as a Date.
asEquation()EquationReturns the current element as an Equation.
asEquationFunction()EquationFunctionReturns the current element as a EquationFunction.
asEquationFunctionArgumentSeparator()EquationFunctionArgumentSeparatorReturns the current element as a EquationFunctionArgumentSeparator.
asEquationSymbol()EquationSymbolReturns the current element as a EquationSymbol.
asFooterSection()FooterSectionReturns the current element as a FooterSection.
asFootnote()FootnoteReturns the current element as a Footnote.
asFootnoteSection()FootnoteSectionReturns the current element as a FootnoteSection.
asHeaderSection()HeaderSectionReturns the current element as a HeaderSection.
asHorizontalRule()HorizontalRuleReturns the current element as a HorizontalRule.
asInlineDrawing()InlineDrawingReturns the current element as a InlineDrawing.
asInlineImage()InlineImageReturns the current element as a InlineImage.
asListItem()ListItemReturns the current element as a ListItem.
asPageBreak()PageBreakReturns the current element as a PageBreak.
asParagraph()ParagraphReturns the current element as a Paragraph.
asPerson()PersonReturns the current element as a Person.
asRichLink()RichLinkReturns the current element as a RichLink, for example, a link to a Google Sheets file.
asTable()TableReturns the current element as a Table.
asTableCell()TableCellReturns the current element as a TableCell.
asTableOfContents()TableOfContentsReturns the current element as a TableOfContents.
asTableRow()TableRowReturns the current element as a TableRow.
asText()TextReturns the current element as a Text.
copy()ElementReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()ElementMerges the element with the preceding sibling of the same type.
removeFromParent()ElementRemoves the element from its parent.
setAttributes(attributes)ElementSets the element's attributes.

ElementType

Properties

PropertyTypeDescription
BODY_SECTIONEnumThe type corresponding to the Body element.
COMMENT_SECTIONEnumThe type corresponding to the CommentSection element.
DATEEnumThe type corresponding to the Date element.
DOCUMENTEnumThe type that corresponds to the root of the document.
EQUATIONEnumThe type corresponding to the Equation element.
EQUATION_FUNCTIONEnumThe type corresponding to the EquationFunction element.
EQUATION_FUNCTION_ARGUMENT_SEPARATOREnumThe type corresponding to the EquationFunctionArgumentSeparator element.
EQUATION_SYMBOLEnumThe type corresponding to the EquationSymbol element.
RICH_LINKEnumThe type corresponding to the RichLink element.
FOOTER_SECTIONEnumThe type corresponding to the FooterSection element.
FOOTNOTEEnumThe type corresponding to the Footnote element.
FOOTNOTE_SECTIONEnumThe type corresponding to the FootnoteSection element.
HEADER_SECTIONEnumThe type corresponding to the HeaderSection element.
HORIZONTAL_RULEEnumThe type corresponding to the HorizontalRule element.
INLINE_DRAWINGEnumThe type corresponding to the InlineDrawing element.
INLINE_IMAGEEnumThe type corresponding to the InlineImage element.
LIST_ITEMEnumThe type corresponding to the ListItem element.
PAGE_BREAKEnumThe type corresponding to the PageBreak element.
PARAGRAPHEnumThe type corresponding to the Paragraph element.
PERSONEnumThe type corresponding to the Person element.
TABLEEnumThe type corresponding to the Table element.
TABLE_CELLEnumThe type corresponding to the TableCell element.
TABLE_OF_CONTENTSEnumThe type corresponding to the TableOfContents element.
TABLE_ROWEnumThe type corresponding to the TableRow element.
TEXTEnumThe type corresponding to the Text element.
UNSUPPORTEDEnumThe type corresponding to UnsupportedElement.

Equation

Methods

MethodReturn typeBrief description
clear()EquationClears the contents of the element.
copy()EquationReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search 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()StringRetrieves the link url.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()EquationMerges the element with the preceding sibling of the same type.
removeFromParent()EquationRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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 a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search 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()StringRetrieves the link url.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()EquationFunctionMerges the element with the preceding sibling of the same type.
removeFromParent()EquationFunctionRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()EquationFunctionArgumentSeparatorMerges the element with the preceding sibling of the same type.
removeFromParent()EquationFunctionArgumentSeparatorRemoves 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()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()EquationSymbolMerges the element with the preceding sibling of the same type.
removeFromParent()EquationSymbolRemoves the element from its parent.
setAttributes(attributes)EquationSymbolSets the element's attributes.

FontFamily

FooterSection

Methods

MethodReturn typeBrief description
appendHorizontalRule()HorizontalRuleCreates and appends a new HorizontalRule.
appendImage(image)InlineImageCreates and appends a new InlineImage from the specified image blob.
appendImage(image)InlineImageAppends the given InlineImage.
appendListItem(listItem)ListItemAppends the given ListItem.
appendListItem(text)ListItemCreates and appends a new ListItem containing the specified text contents.
appendParagraph(paragraph)ParagraphAppends the given Paragraph.
appendParagraph(text)ParagraphCreates and appends a new Paragraph containing the specified text contents.
appendTable()TableCreates and appends a new Table.
appendTable(cells)TableAppends a new Table containing a TableCell for each specified string value.
appendTable(table)TableAppends the given Table.
clear()FooterSectionClears the contents of the element.
copy()FooterSectionReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search 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[]Retrieves all the InlineImages contained in the section.
getListItems()ListItem[]Retrieves all the ListItems contained in the section.
getNumChildren()IntegerRetrieves the number of children.
getParagraphs()Paragraph[]Retrieves all the Paragraphs contained in the section (including ListItems).
getParent()ContainerElementRetrieves the element's parent element.
getTables()Table[]Retrieves all the Tables contained in the section.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a new HorizontalRule at the specified index.
insertImage(childIndex, image)InlineImageCreates and inserts an InlineImage from the specified image blob, at the specified index.
insertImage(childIndex, image)InlineImageInserts the given InlineImage at the specified index.
insertListItem(childIndex, listItem)ListItemInserts the given ListItem at the specified index.
insertListItem(childIndex, text)ListItemCreates and inserts a new ListItem at the specified index, containing the specified text contents.
insertParagraph(childIndex, paragraph)ParagraphInserts the given Paragraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a new Paragraph at the specified index, containing the specified text contents.
insertTable(childIndex)TableCreates and inserts a new Table at the specified index.
insertTable(childIndex, cells)TableCreates and inserts a new Table containing the specified cells, at the specified index.
insertTable(childIndex, table)TableInserts the given Table at the specified index.
removeChild(child)FooterSectionRemoves the specified child element.
removeFromParent()FooterSectionRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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()FootnoteSectionRetrieves the contents of the footnote element.
getNextSibling()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
removeFromParent()FootnoteRemoves the element from its parent.
setAttributes(attributes)FootnoteSets the element's attributes.

FootnoteSection

Methods

MethodReturn typeBrief description
appendParagraph(paragraph)ParagraphAppends the given Paragraph.
appendParagraph(text)ParagraphCreates and appends a new Paragraph containing the specified text contents.
clear()FootnoteSectionClears the contents of the element.
copy()FootnoteSectionReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search 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()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParagraphs()Paragraph[]Retrieves all the Paragraphs contained in the section (including ListItems).
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
insertParagraph(childIndex, paragraph)ParagraphInserts the given Paragraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a new Paragraph at the specified index, containing the specified text contents.
removeChild(child)FootnoteSectionRemoves the specified child element.
removeFromParent()FootnoteSectionRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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 new HorizontalRule.
appendImage(image)InlineImageCreates and appends a new InlineImage from the specified image blob.
appendImage(image)InlineImageAppends the given InlineImage.
appendListItem(listItem)ListItemAppends the given ListItem.
appendListItem(text)ListItemCreates and appends a new ListItem containing the specified text contents.
appendParagraph(paragraph)ParagraphAppends the given Paragraph.
appendParagraph(text)ParagraphCreates and appends a new Paragraph containing the specified text contents.
appendTable()TableCreates and appends a new Table.
appendTable(cells)TableAppends a new Table containing a TableCell for each specified string value.
appendTable(table)TableAppends the given Table.
clear()HeaderSectionClears the contents of the element.
copy()HeaderSectionReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search 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[]Retrieves all the InlineImages contained in the section.
getListItems()ListItem[]Retrieves all the ListItems contained in the section.
getNumChildren()IntegerRetrieves the number of children.
getParagraphs()Paragraph[]Retrieves all the Paragraphs contained in the section (including ListItems).
getParent()ContainerElementRetrieves the element's parent element.
getTables()Table[]Retrieves all the Tables contained in the section.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a new HorizontalRule at the specified index.
insertImage(childIndex, image)InlineImageCreates and inserts an InlineImage from the specified image blob, at the specified index.
insertImage(childIndex, image)InlineImageInserts the given InlineImage at the specified index.
insertListItem(childIndex, listItem)ListItemInserts the given ListItem at the specified index.
insertListItem(childIndex, text)ListItemCreates and inserts a new ListItem at the specified index, containing the specified text contents.
insertParagraph(childIndex, paragraph)ParagraphInserts the given Paragraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a new Paragraph at the specified index, containing the specified text contents.
insertTable(childIndex)TableCreates and inserts a new Table at the specified index.
insertTable(childIndex, cells)TableCreates and inserts a new Table containing the specified cells, at the specified index.
insertTable(childIndex, table)TableInserts the given Table at the specified index.
removeChild(child)HeaderSectionRemoves the specified child element.
removeFromParent()HeaderSectionRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
removeFromParent()HorizontalRuleRemoves 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()StringReturns the drawing's alternate description.
getAltTitle()StringReturns the drawing's alternate title.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()InlineDrawingMerges the element with the preceding sibling of the same type.
removeFromParent()InlineDrawingRemoves 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()StringReturns the image's alternate description.
getAltTitle()StringReturns 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()StringRetrieves the link URL.
getNextSibling()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
getWidth()IntegerRetrieves the image's width, in pixels.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()InlineImageMerges the element with the preceding sibling of the same type.
removeFromParent()InlineImageRemoves 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 new PositionedImage from the specified image blob.
appendHorizontalRule()HorizontalRuleCreates and appends a new HorizontalRule.
appendInlineImage(image)InlineImageCreates and appends a new InlineImage from the specified image blob.
appendInlineImage(image)InlineImageAppends the given InlineImage.
appendPageBreak()PageBreakCreates and appends a new PageBreak.
appendPageBreak(pageBreak)PageBreakAppends the given PageBreak.
appendText(text)TextCreates and appends a new Text element with the specified contents.
appendText(text)TextAppends the given Text element.
clear()ListItemClears the contents of the element.
copy()ListItemReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search result.
getAlignment()HorizontalAlignmentRetrieves the HorizontalAlignment.
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()GlyphTypeRetrieves the list item's GlyphType.
getHeading()ParagraphHeadingRetrieves the ParagraphHeading.
getIndentEnd()NumberRetrieves the end indentation, in points.
getIndentFirstLine()NumberRetrieves the first line indentation, in points.
getIndentStart()NumberRetrieves the start indentation.
getLineSpacing()NumberRetrieves the line spacing, in points.
getLinkUrl()StringRetrieves the link url.
getListId()StringRetrieves the list ID.
getNestingLevel()IntegerRetrieves the list item's nesting level.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElementRetrieves the element's parent element.
getPositionedImage(id)PositionedImageGets a PositionedImage by the image's ID.
getPositionedImages()PositionedImage[]Gets all PositionedImage objects anchored to the paragraph.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getSpacingAfter()NumberRetrieves the spacing after the element, in points.
getSpacingBefore()NumberRetrieves the spacing before the element, in points.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a HorizontalRule at the specified index.
insertInlineImage(childIndex, image)InlineImageCreates and inserts a new InlineImage from the specified image blob, at the specified index.
insertInlineImage(childIndex, image)InlineImageInserts the given InlineImage at the specified index.
insertPageBreak(childIndex)PageBreakCreates and inserts a new PageBreak at the specified index.
insertPageBreak(childIndex, pageBreak)PageBreakInserts the given PageBreak at the specified index.
insertText(childIndex, text)TextCreates and inserts a new text element at the specified index.
insertText(childIndex, text)TextInserts the given Text element at the specified index, with the specified text contents.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
isLeftToRight()BooleanRetrieves the left-to-right setting.
merge()ListItemMerges the element with the preceding sibling of the same type.
removeChild(child)ListItemRemoves the specified child element.
removeFromParent()ListItemRemoves the element from its parent.
removePositionedImage(id)BooleanRemoves a PositionedImage by the image's ID.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
setAlignment(alignment)ListItemSets the HorizontalAlignment.
setAttributes(attributes)ListItemSets the element's attributes.
setGlyphType(glyphType)ListItemSets the list item's GlyphType.
setHeading(heading)ListItemSets the ParagraphHeading.
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 this NamedRange.
getName()StringGets the name of this NamedRange.
getRange()RangeGets the range of elements associated with this NamedRange.
remove()voidRemoves this NamedRange from the document.

PageBreak

Methods

MethodReturn typeBrief description
copy()PageBreakReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getNextSibling()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
removeFromParent()PageBreakRemoves the element from its parent.
setAttributes(attributes)PageBreakSets the element's attributes.

Paragraph

Methods

MethodReturn typeBrief description
addPositionedImage(image)PositionedImageCreates and inserts a new PositionedImage from the specified image blob.
appendHorizontalRule()HorizontalRuleCreates and appends a new HorizontalRule.
appendInlineImage(image)InlineImageCreates and appends a new InlineImage from the specified image blob.
appendInlineImage(image)InlineImageAppends the given InlineImage.
appendPageBreak()PageBreakCreates and appends a new PageBreak.
appendPageBreak(pageBreak)PageBreakAppends the given PageBreak.
appendText(text)TextCreates and appends a new Text element with the specified contents.
appendText(text)TextAppends the given Text element.
clear()ParagraphClears the contents of the element.
copy()ParagraphReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search result.
getAlignment()HorizontalAlignmentRetrieves the HorizontalAlignment.
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()ParagraphHeadingRetrieves the ParagraphHeading.
getIndentEnd()NumberRetrieves the end indentation, in points.
getIndentFirstLine()NumberRetrieves the first line indentation, in points.
getIndentStart()NumberRetrieves the start indentation.
getLineSpacing()NumberRetrieves the line spacing, in points.
getLinkUrl()StringRetrieves the link url.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElementRetrieves the element's parent element.
getPositionedImage(id)PositionedImageGets a PositionedImage by the image's ID.
getPositionedImages()PositionedImage[]Gets all PositionedImage objects anchored to the paragraph.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getSpacingAfter()NumberRetrieves the spacing after the element, in points.
getSpacingBefore()NumberRetrieves the spacing before the element, in points.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a HorizontalRule at the specified index.
insertInlineImage(childIndex, image)InlineImageCreates and inserts a new InlineImage from the specified image blob, at the specified index.
insertInlineImage(childIndex, image)InlineImageInserts the given InlineImage at the specified index.
insertPageBreak(childIndex)PageBreakCreates and inserts a new PageBreak at the specified index.
insertPageBreak(childIndex, pageBreak)PageBreakInserts the given PageBreak at the specified index.
insertText(childIndex, text)TextCreates and inserts a new text element at the specified index.
insertText(childIndex, text)TextInserts the given Text element at the specified index, with the specified text contents.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
isLeftToRight()BooleanRetrieves the left-to-right setting.
merge()ParagraphMerges the element with the preceding sibling of the same type.
removeChild(child)ParagraphRemoves the specified child element.
removeFromParent()ParagraphRemoves the element from its parent.
removePositionedImage(id)BooleanRemoves a PositionedImage by the image's ID.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
setAlignment(alignment)ParagraphSets the HorizontalAlignment.
setAttributes(attributes)ParagraphSets the element's attributes.
setHeading(heading)ParagraphSets the ParagraphHeading.
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()StringReturns the person's display name, if set.
getNextSibling()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()PersonMerges the element with the preceding sibling of the same type.
removeFromParent()PersonRemoves the element from its parent.
setAttributes(attributes)PersonSets the element's attributes.

Position

Methods

MethodReturn typeBrief description
getElement()ElementGets the element that contains this Position.
getOffset()IntegerGets this Position's relative location within the element that contains it.
getSurroundingText()TextCreates an artificial Text element that represents the text and formatting of the Paragraph or ListItem that contains the Position, either directly or through a chain of child elements.
getSurroundingTextOffset()IntegerGets the offset of this Position within the Text element returned by getSurroundingText().
insertBookmark()BookmarkCreates and inserts a new Bookmark at this Position.
insertInlineImage(image)InlineImageCreates and inserts a new InlineImage at this Position from the specified image blob.
insertText(text)TextInserts the specified text at this Position.

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 the Paragraph 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 this Range, including any partial Text elements (for example, in the case of a selection that includes only part of a Text element).

RangeBuilder

Methods

MethodReturn typeBrief description
addElement(element)RangeBuilderAdds an entire Element to this RangeBuilder.
addElement(textElement, startOffset, endOffsetInclusive)RangeBuilderAdds a partial Text element to this RangeBuilder.
addElementsBetween(startElement, endElementInclusive)RangeBuilderAdds two entire elements, and all elements between them, to this RangeBuilder.
addElementsBetween(startTextElement, startOffset, endTextElementInclusive, endOffsetInclusive)RangeBuilderAdds two partial Text elements, and all elements between them, to the RangeBuilder.
addRange(range)RangeBuilderAdds the contents of another Range to this RangeBuilder.
build()RangeConstructs a Range from the settings applied to the builder.
getRangeElements()RangeElement[]Gets all elements in this Range, including any partial Text elements (for example, in the case of a selection that includes only part of a Text element).

RangeElement

Methods

MethodReturn typeBrief description
getElement()ElementGets the Element that corresponds to this RangeElement.
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 the element's characters.

Methods

MethodReturn typeBrief description
copy()RichLinkReturns a detached, deep copy of the current element.
getAttributes()ObjectRetrieves the element's attributes.
getMimeType()StringReturns the MIME type of the link, which is available when the item is a link to a Drive file and null otherwise.
getNextSibling()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getTitle()StringReturns the link's displayed title.
getType()ElementTypeRetrieves the element's ElementType.
getUrl()StringReturns the URL of the resource.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()RichLinkMerges the element with the preceding sibling of the same type.
removeFromParent()RichLinkRemoves the element from its parent.
setAttributes(attributes)RichLinkSets the element's attributes.

Table

Methods

MethodReturn typeBrief description
appendTableRow()TableRowCreates and appends a new TableRow.
appendTableRow(tableRow)TableRowAppends the given TableRow.
clear()TableClears the contents of the element.
copy()TableReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search result.
getAttributes()ObjectRetrieves the element's attributes.
getBorderColor()StringRetrieves the border color.
getBorderWidth()NumberRetrieves the border width, in points.
getCell(rowIndex, cellIndex)TableCellRetrieves the TableCell 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)NumberRetrieves the width of the specified table column, in points.
getLinkUrl()StringRetrieves the link url.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getNumRows()IntegerRetrieves the number of TableRows.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getRow(rowIndex)TableRowRetrieves the TableRow at the specified row index.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
insertTableRow(childIndex)TableRowCreates and inserts a new TableRow at the specified index.
insertTableRow(childIndex, tableRow)TableRowInserts the given TableRow at the specified index.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
removeChild(child)TableRemoves the specified child element.
removeFromParent()TableRemoves the element from its parent.
removeRow(rowIndex)TableRowRemoves the TableRow at the specified row index.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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 new HorizontalRule.
appendImage(image)InlineImageCreates and appends a new InlineImage from the specified image blob.
appendImage(image)InlineImageAppends the given InlineImage.
appendListItem(listItem)ListItemAppends the given ListItem.
appendListItem(text)ListItemCreates and appends a new ListItem.
appendParagraph(paragraph)ParagraphAppends the given Paragraph.
appendParagraph(text)ParagraphCreates and appends a new Paragraph.
appendTable()TableCreates and appends a new Table.
appendTable(cells)TableAppends a new Table containing the specified cells.
appendTable(table)TableAppends the given Table.
clear()TableCellClears the contents of the element.
copy()TableCellReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search result.
getAttributes()ObjectRetrieves the element's attributes.
getBackgroundColor()StringRetrieves 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()StringRetrieves the link url.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getPaddingBottom()NumberRetrieves the bottom padding, in points.
getPaddingLeft()NumberRetrieves the left padding, in points.
getPaddingRight()NumberRetrieves the right padding, in points.
getPaddingTop()NumberRetrieves the top padding, in points.
getParent()ContainerElementRetrieves the element's parent element.
getParentRow()TableRowRetrieves the TableRow containing the current TableCell.
getParentTable()TableRetrieves the Table containing the current TableCell.
getPreviousSibling()ElementRetrieves 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()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
getVerticalAlignment()VerticalAlignmentRetrieves the VerticalAlignment.
getWidth()NumberRetrieves the width of the column containing the cell, in points.
insertHorizontalRule(childIndex)HorizontalRuleCreates and inserts a new HorizontalRule at the specified index.
insertImage(childIndex, image)InlineImageCreates and inserts an InlineImage from the specified image blob, at the specified index.
insertImage(childIndex, image)InlineImageInserts the given InlineImage at the specified index.
insertListItem(childIndex, listItem)ListItemInserts the given ListItem at the specified index.
insertListItem(childIndex, text)ListItemCreates and inserts a new ListItem at the specified index.
insertParagraph(childIndex, paragraph)ParagraphInserts the given Paragraph at the specified index.
insertParagraph(childIndex, text)ParagraphCreates and inserts a new Paragraph at the specified index.
insertTable(childIndex)TableCreates and inserts a new Table at the specified index.
insertTable(childIndex, cells)TableCreates and inserts a new Table containing the specified cells, at the specified index.
insertTable(childIndex, table)TableInserts the given Table at the specified index.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()TableCellMerges the element with the preceding sibling of the same type.
removeChild(child)TableCellRemoves the specified child element.
removeFromParent()TableCellRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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 a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search 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()StringRetrieves the link url.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
removeFromParent()TableOfContentsRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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 new TableCell.
appendTableCell(textContents)TableCellAppends the given TableCell containing the specified text.
appendTableCell(tableCell)TableCellAppends the given TableCell.
clear()TableRowClears the contents of the element.
copy()TableRowReturns a detached, deep copy of the current element.
editAsText()TextObtains a Text version of the current element, for editing.
findElement(elementType)RangeElementSearches the contents of the element for a descendant of the specified type.
findElement(elementType, from)RangeElementSearches the contents of the element for a descendant of the specified type, starting from the specified RangeElement.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search result.
getAttributes()ObjectRetrieves the element's attributes.
getCell(cellIndex)TableCellRetrieves the TableCell 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()StringRetrieves the link url.
getMinimumHeight()NumberRetrieves the minimum height, in points.
getNextSibling()ElementRetrieves the element's next sibling element.
getNumCells()IntegerRetrieves the number of cells in the row.
getNumChildren()IntegerRetrieves the number of children.
getParent()ContainerElementRetrieves the element's parent element.
getParentTable()TableRetrieves the Table containing the current row.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getType()ElementTypeRetrieves the element's ElementType.
insertTableCell(childIndex)TableCellCreates and inserts a new TableCell at the specified index.
insertTableCell(childIndex, textContents)TableCellInserts the given TableCell at the specified index, containing the given text.
insertTableCell(childIndex, tableCell)TableCellInserts the given TableCell at the specified index.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()TableRowMerges the element with the preceding sibling of the same type.
removeCell(cellIndex)TableCellRemoves the TableCell at the specified cell index.
removeChild(child)TableRowRemoves the specified child element.
removeFromParent()TableRowRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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 a Text version of the current element, for editing.
findText(searchPattern)RangeElementSearches the contents of the element for the specified text pattern using regular expressions.
findText(searchPattern, from)RangeElementSearches the contents of the element for the specified text pattern, starting from a given search result.
getAttributes()ObjectRetrieves the element's attributes.
getAttributes(offset)ObjectRetrieves the attributes at the specified character offset.
getBackgroundColor()StringRetrieves the background color setting.
getBackgroundColor(offset)StringRetrieves the background color at the specified character offset.
getFontFamily()StringRetrieves the font family setting.
getFontFamily(offset)StringRetrieves the font family at the specified character offset.
getFontSize()NumberRetrieves the font size setting.
getFontSize(offset)NumberRetrieves the font size at the specified character offset.
getForegroundColor()StringRetrieves the foreground color setting.
getForegroundColor(offset)StringRetrieves the foreground color at the specified character offset.
getLinkUrl()StringRetrieves the link url.
getLinkUrl(offset)StringRetrieves the link URL at the specified character offset.
getNextSibling()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getText()StringRetrieves the contents of the element as a text string.
getTextAlignment()TextAlignmentGets the text alignment.
getTextAlignment(offset)TextAlignmentGets the text alignment for a single character.
getTextAttributeIndices()Integer[]Retrieves the set of text indices that correspond to the start of distinct text formatting runs.
getType()ElementTypeRetrieves the element's ElementType.
insertText(offset, text)TextInserts the specified text at the given character offset.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
isBold()BooleanRetrieves the bold setting.
isBold(offset)BooleanRetrieves the bold setting at the specified character offset.
isItalic()BooleanRetrieves the italic setting.
isItalic(offset)BooleanRetrieves the italic setting at the specified character offset.
isStrikethrough()BooleanRetrieves the strikethrough setting.
isStrikethrough(offset)BooleanRetrieves the strikethrough setting at the specified character offset.
isUnderline()BooleanRetrieves the underline setting.
isUnderline(offset)BooleanRetrieves the underline setting at the specified character offset.
merge()TextMerges the element with the preceding sibling of the same type.
removeFromParent()TextRemoves the element from its parent.
replaceText(searchPattern, replacement)ElementReplaces all occurrences of a given text pattern with a given replacement string, using regular expressions.
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()ElementRetrieves the element's next sibling element.
getParent()ContainerElementRetrieves the element's parent element.
getPreviousSibling()ElementRetrieves the element's previous sibling element.
getType()ElementTypeRetrieves the element's ElementType.
isAtDocumentEnd()BooleanDetermines whether the element is at the end of the Document.
merge()UnsupportedElementMerges the element with the preceding sibling of the same type.
removeFromParent()UnsupportedElementRemoves 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.