vertical_anchor property
TextBox.vertical_anchor property
Specifies the vertical alignment of the text within a shape.
@property
def vertical_anchor(self) -> aspose.words.drawing.TextBoxAnchor:
...
@vertical_anchor.setter
def vertical_anchor(self, value: aspose.words.drawing.TextBoxAnchor):
...
Remarks
The default value is TextBoxAnchor.TOP.
Examples
Shows how to vertically align the text contents of a text box.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
shape = builder.insert_shape(shape_type=aw.drawing.ShapeType.TEXT_BOX, width=200, height=200)
# Set the "VerticalAnchor" property to "TextBoxAnchor.Top" to
# align the text in this text box with the top side of the shape.
# Set the "VerticalAnchor" property to "TextBoxAnchor.Middle" to
# align the text in this text box to the center of the shape.
# Set the "VerticalAnchor" property to "TextBoxAnchor.Bottom" to
# align the text in this text box to the bottom of the shape.
shape.text_box.vertical_anchor = vertical_anchor
builder.move_to(shape.first_paragraph)
builder.write('Hello world!')
# The vertical aligning of text inside text boxes is available from Microsoft Word 2007 onwards.
doc.compatibility_options.optimize_for(aw.settings.MsWordVersion.WORD2007)
doc.save(file_name=ARTIFACTS_DIR + 'Shape.VerticalAnchor.docx')
See Also
- module aspose.words.drawing
- class TextBox