Enum HorizontalAlignment

  • HorizontalAlignment is an enumeration of supported horizontal alignment types.

  • You call an enum by calling its parent class, name, and property, such asDocumentApp.HorizontalAlignment.LEFT.

  • TheHorizontalAlignment enumeration is used to manipulate the alignment of Paragraph contents.

  • Properties include LEFT, CENTER, RIGHT, and JUSTIFY alignment options.

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 theHorizontalAlignment enumeration to manipulate the alignment ofParagraph contents.

constbody=DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();// Insert a paragraph and a table at the start of the tab.constpar1=body.insertParagraph(0,'Center');consttable=body.insertTable(1,[['Left','Right']]);constpar2=table.getCell(0,0).getChild(0).asParagraph();constpar3=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

PropertyTypeDescription
LEFTEnumThe left-alignment option.
CENTEREnumThe center-alignment option.
RIGHTEnumThe right-alignment option.
JUSTIFYEnumThe justify-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.