Enum Attribute

Attribute

An enumeration of the element attributes.

To call an enum, you call its parent class, name, and property. For example, DocumentApp.Attribute.BACKGROUND_COLOR.

Use attributes to compose custom styles. For example:

// Define a style with yellow background.
const highlightStyle = {};
highlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00';
highlightStyle[DocumentApp.Attribute.BOLD] = true;

// Insert "Hello", highlighted.
DocumentApp.getActiveDocument()
    .getActiveTab()
    .asDocumentTab()
    .editAsText()
    .insertText(0, 'Hello\n')
    .setAttributes(0, 4, highlightStyle);

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. The default link style (foreground color, underline) is automatically applied.
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.