Aspose::Words::Drawing::TextBox::get_FitShapeToText method

TextBox::get_FitShapeToText method

Determines whether Microsoft Word will grow the shape to fit text.

bool Aspose::Words::Drawing::TextBox::get_FitShapeToText()

Remarks

The default value is false.

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");

See Also