Enum HorizontalAlignment | Apps Script | Google for Developers (original) (raw)
Enum HorizontalAlignment
Stay organized with collections Save and categorize content based on your preferences.
HorizontalAlignment
An enumeration of the supported horizontal alignment types.
To call an enum, you call its parent class, name, and property. For example, DocumentApp.HorizontalAlignment.LEFT
.
Use the HorizontalAlignment
enumeration to manipulate the alignment of [Paragraph](/apps-script/reference/document/paragraph)
contents.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();
// Insert a paragraph and a table at the start of the tab. const par1 = body.insertParagraph(0, 'Center'); const table = body.insertTable(1, [['Left', 'Right']]); const par2 = table.getCell(0, 0).getChild(0).asParagraph(); const par3 = table.getCell(0, 0).getChild(0).asParagraph();
// Center align the first paragraph. par1.setAlignment(DocumentApp.HorizontalAlignment.CENTER);
// Left align the first cell. par2.setAlignment(DocumentApp.HorizontalAlignment.LEFT);
// Right align the second cell. par3.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
Properties
Property | Type | Description |
---|---|---|
LEFT | Enum | The left-alignment option. |
CENTER | Enum | The center-alignment option. |
RIGHT | Enum | The right-alignment option. |
JUSTIFY | Enum | The justify-alignment option. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.