Enum HorizontalAlignment
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
تراز افقی شمارشی از انواع تراز افقی پشتیبانی شده.
برای فراخوانی یک enum، کلاس والد، نام و ویژگی آن را فراخوانی می کنید. برای مثال، DocumentApp.HorizontalAlignment.LEFT
.
از شمارش Horizontal Alignment
برای دستکاری تراز محتویات Paragraph
استفاده کنید.
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);
خواص
اموال | تایپ کنید | توضیحات |
---|
LEFT | Enum | گزینه تراز چپ. |
CENTER | Enum | گزینه تراز وسط. |
RIGHT | Enum | گزینه تراز راست. |
JUSTIFY | Enum | گزینه justify-alignment. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003e\u003ccode\u003eHorizontalAlignment\u003c/code\u003e is used to set the horizontal alignment of paragraph content within Google Docs.\u003c/p\u003e\n"],["\u003cp\u003eIt provides options for left, center, right, and justify alignment through its properties (\u003ccode\u003eLEFT\u003c/code\u003e, \u003ccode\u003eCENTER\u003c/code\u003e, \u003ccode\u003eRIGHT\u003c/code\u003e, \u003ccode\u003eJUSTIFY\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eYou can access these alignment options using the syntax \u003ccode\u003eDocumentApp.HorizontalAlignment.ALIGNMENT_TYPE\u003c/code\u003e, where \u003ccode\u003eALIGNMENT_TYPE\u003c/code\u003e is one of the properties mentioned above.\u003c/p\u003e\n"]]],[],null,["# Enum HorizontalAlignment\n\nHorizontalAlignment\n\nAn enumeration of the supported horizontal alignment types.\n\nTo call an enum, you call its parent class, name, and property. For example, `\nDocumentApp.HorizontalAlignment.LEFT`.\n\nUse the `Horizontal``Alignment` enumeration to manipulate the alignment of [Paragraph](/apps-script/reference/document/paragraph) contents.\n\n```javascript\nconst body =\n DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();\n\n// Insert a paragraph and a table at the start of the tab.\nconst par1 = body.insertParagraph(0, 'Center');\nconst table = body.insertTable(1, [['Left', 'Right']]);\nconst par2 = table.getCell(0, 0).getChild(0).asParagraph();\nconst par3 = table.getCell(0, 0).getChild(0).asParagraph();\n\n// Center align the first paragraph.\npar1.setAlignment(DocumentApp.HorizontalAlignment.CENTER);\n\n// Left align the first cell.\npar2.setAlignment(DocumentApp.HorizontalAlignment.LEFT);\n\n// Right align the second cell.\npar3.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);\n``` \n\n### Properties\n\n| Property | Type | Description |\n|-----------|--------|-------------------------------|\n| `LEFT` | `Enum` | The left-alignment option. |\n| `CENTER` | `Enum` | The center-alignment option. |\n| `RIGHT` | `Enum` | The right-alignment option. |\n| `JUSTIFY` | `Enum` | The justify-alignment option. |"]]