Aspose::Words::Drawing::TextBox class

TextBox class

Defines attributes that specify how a text is displayed inside a shape. To learn more, visit the Working with Shapes documentation article.

class TextBox : public System::Object

Methods

MethodDescription
BreakForwardLink()Breaks the link to the next TextBox.
get_FitShapeToText()Determines whether Microsoft Word will grow the shape to fit text.
get_InternalMarginBottom()Specifies the inner bottom margin in points for a shape.
get_InternalMarginLeft()Specifies the inner left margin in points for a shape.
get_InternalMarginRight()Specifies the inner right margin in points for a shape.
get_InternalMarginTop()Specifies the inner top margin in points for a shape.
get_LayoutFlow()Determines the flow of the text layout in a shape.
get_Next()Returns or sets a TextBox that represents the next TextBox in a sequence of shapes.
get_NoTextRotation()Gets a boolean value indicating either text of the TextBox should not rotate when the shape is rotated.
get_Parent() constGets a parent shape for the TextBox.
get_Previous()Returns a TextBox that represents the previous TextBox in a sequence of shapes.
get_TextBoxWrapMode()Determines how text wraps inside a shape.
get_VerticalAnchor()Specifies the vertical alignment of the text within a shape.
GetType() const override
Is(const System::TypeInfo&) const override
IsValidLinkTarget(const System::SharedPtr<Aspose::Words::Drawing::TextBox>&)Determines whether this TextBox can be linked to the target TextBox.
set_FitShapeToText(bool)Setter for Aspose::Words::Drawing::TextBox::get_FitShapeToText.
set_InternalMarginBottom(double)Setter for Aspose::Words::Drawing::TextBox::get_InternalMarginBottom.
set_InternalMarginLeft(double)Setter for Aspose::Words::Drawing::TextBox::get_InternalMarginLeft.
set_InternalMarginRight(double)Setter for Aspose::Words::Drawing::TextBox::get_InternalMarginRight.
set_InternalMarginTop(double)Setter for Aspose::Words::Drawing::TextBox::get_InternalMarginTop.
set_LayoutFlow(Aspose::Words::Drawing::LayoutFlow)Determines the flow of the text layout in a shape.
set_Next(const System::SharedPtr<Aspose::Words::Drawing::TextBox>&)Setter for Aspose::Words::Drawing::TextBox::get_Next.
set_NoTextRotation(bool)Sets a boolean value indicating either text of the TextBox should not rotate when the shape is rotated.
set_TextBoxWrapMode(Aspose::Words::Drawing::TextBoxWrapMode)Setter for Aspose::Words::Drawing::TextBox::get_TextBoxWrapMode.
set_VerticalAnchor(Aspose::Words::Drawing::TextBoxAnchor)Setter for Aspose::Words::Drawing::TextBox::get_VerticalAnchor.
static Type()

Remarks

Use the TextBox property to access text properties of a shape. You do not create instances of the TextBox class directly.

Examples

Shows how to get a text box to resize itself to fit its contents tightly.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

SharedPtr<Shape> textBoxShape = builder->InsertShape(ShapeType::TextBox, 150, 100);
SharedPtr<TextBox> textBox = textBoxShape->get_TextBox();

// Apply these values to both these members to get the parent shape to fit
// tightly around the text contents, ignoring the dimensions we have set.
textBox->set_FitShapeToText(true);
textBox->set_TextBoxWrapMode(TextBoxWrapMode::None);

builder->MoveTo(textBoxShape->get_LastParagraph());
builder->Write(u"Text fit tightly inside textbox.");

doc->Save(ArtifactsDir + u"Shape.TextBoxFitShapeToText.docx");

Shows how to set internal margins for a text box.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

// Insert another textbox with specific margins.
SharedPtr<Shape> textBoxShape = builder->InsertShape(ShapeType::TextBox, 100, 100);
SharedPtr<TextBox> textBox = textBoxShape->get_TextBox();
textBox->set_InternalMarginTop(15);
textBox->set_InternalMarginBottom(15);
textBox->set_InternalMarginLeft(15);
textBox->set_InternalMarginRight(15);

builder->MoveTo(textBoxShape->get_LastParagraph());
builder->Write(u"Text placed according to textbox margins.");

doc->Save(ArtifactsDir + u"Shape.TextBoxMargins.docx");

See Also