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 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);
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-26 UTC."],[[["`HorizontalAlignment` is used to set the horizontal alignment of paragraph content within Google Docs."],["It provides options for left, center, right, and justify alignment through its properties (`LEFT`, `CENTER`, `RIGHT`, `JUSTIFY`)."],["You can access these alignment options using the syntax `DocumentApp.HorizontalAlignment.ALIGNMENT_TYPE`, where `ALIGNMENT_TYPE` is one of the properties mentioned above."]]],[]]