search/mag_sel search/close
Aspose::Words::Drawing Namespace Reference

The Aspose.Words.Drawing namespace provides classes that allow to create and modify drawing objects.

All drawing objects in Microsoft Word documents are represented by instances of the Shape and GroupShape classes. An object of the Shape class is a node in a document and can represent a picture, textbox, AutoShape or an OLE object.

The classes in this namespace support the latest (Word 2007 - 2013 DrawingML) and the earlier (pre Word 2007 - Office Art) shapes.

Namespaces

 Charts
 The Aspose.Words.Drawing.Charts namespace provides classes that allow to access charts in Microsoft Word documents.
 
 Core
 The Aspose.Words.Drawing namespace contains classes that allow to create and modify drawing objects in Microsoft Word documents.
 

Classes

class  Fill
 Represents fill formatting for an object. More...
 
class  GroupShape
 Represents a group of shapes in a document. More...
 
class  HorizontalRuleFormat
 Represents horizontal rule formatting. More...
 
class  ImageData
 Defines an image for a shape. More...
 
class  ImageSize
 Contains information about image size and resolution. More...
 
class  OleFormat
 Provides access to the data of an OLE object or ActiveX control. More...
 
class  OlePackage
 Allows to access OLE Package properties. More...
 
class  Shape
 Represents an object in the drawing layer, such as an AutoShape, textbox, freeform, OLE object, ActiveX control, or picture. More...
 
class  ShapeBase
 Base class for objects in the drawing layer, such as an AutoShape, freeform, OLE object, ActiveX control, or picture. More...
 
class  SignatureLine
 Provides access to signature line properties. More...
 
class  Stroke
 Defines a stroke for a shape. More...
 
class  TextBox
 Defines attributes that specify how a text is displayed inside a shape. More...
 
class  TextPath
 Defines the text and formatting of the text path (of a WordArt object). More...
 

Enumerations

enum class  ArrowLength
 Length of the arrow at the end of a line. More...
 
enum class  ArrowType
 Specifies the type of an arrow at a line end. More...
 
enum class  ArrowWidth
 Width of the arrow at the end of a line. More...
 
enum class  DashStyle
 Dashed line style. More...
 
enum class  EndCap
 Specifies line cap style. More...
 
enum class  FillType
 Specifies fill type for a fillable object. More...
 
enum class  FlipOrientation
 Possible values for the orientation of a shape. More...
 
enum class  HorizontalAlignment
 Specifies horizontal alignment of a floating shape, text frame or floating table. More...
 
enum class  HorizontalRuleAlignment
 Represents the alignment for the specified horizontal rule. More...
 
enum class  ImageType
 Specifies the type (format) of an image in a Microsoft Word document. More...
 
enum class  JoinStyle
 Line join style. More...
 
enum class  LayoutFlow
 Determines the flow of the text layout in a textbox. More...
 
enum class  PresetTexture
 Specifies texture to be used to fill a shape. More...
 
enum class  RelativeHorizontalPosition
 Specifies to what the horizontal position of a shape or text frame is relative. More...
 
enum class  RelativeVerticalPosition
 Specifies to what the vertical position of a shape or text frame is relative. More...
 
enum class  ShapeLineStyle
 Specifies the compound line style of a Shape. More...
 
enum class  ShapeMarkupLanguage : uint8_t
 Specifies Markup language used for the shape. More...
 
enum class  ShapeType
 Specifies the type of shape in a Microsoft Word document. More...
 
enum class  TextBoxAnchor
 Specifies values used for shape text vertical alignment. More...
 
enum class  TextBoxWrapMode
 Specifies how text wraps inside a shape. More...
 
enum class  TextPathAlignment
 WordArt alignment. More...
 
enum class  VerticalAlignment
 Specifies vertical alignment of a floating shape, text frame or a floating table. More...
 
enum class  WrapSide
 Specifies what side(s) of the shape or picture the text wraps around. More...
 
enum class  WrapType
 Specifies how text is wrapped around a shape or picture. More...
 

Enumeration Type Documentation

◆ ArrowLength

Length of the arrow at the end of a line.

See also
Aspose::Words::Drawing::Stroke::get_StartArrowLength
Aspose::Words::Drawing::Stroke::get_EndArrowLength
Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are four examples of shapes that we can insert into our documents.
// 1 - Dotted, horizontal, half-transparent red line
// with an arrow on the left end and a diamond on the right end:
auto arrow = MakeObject<Shape>(doc, ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// 2 - Thick black diagonal line with rounded ends:
auto line = MakeObject<Shape>(doc, ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(EndCap::Round);
builder->InsertNode(line);
// 3 - Arrow with a green fill:
auto filledInArrow = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_ForeColor(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_Visible(true);
builder->InsertNode(filledInArrow);
// 4 - Arrow with a flipped orientation filled in with the Aspose logo:
auto filledInArrowImg = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = System::IO::File::ReadAllBytes(ImageDir + u"Logo.jpg");
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flip the orientation of our arrow, we also flip the image that the arrow contains.
// Flip the image the other way to cancel this out before getting the shape to display it.
image->RotateFlip(System::Drawing::RotateFlipType::RotateNoneFlipXY);
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");
Enumerator
Short 
Medium 
Long 
Default 

Same as Short.

◆ ArrowType

Specifies the type of an arrow at a line end.

See also
Aspose::Words::Drawing::Stroke::get_StartArrowType
Aspose::Words::Drawing::Stroke::get_EndArrowType
Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are four examples of shapes that we can insert into our documents.
// 1 - Dotted, horizontal, half-transparent red line
// with an arrow on the left end and a diamond on the right end:
auto arrow = MakeObject<Shape>(doc, ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// 2 - Thick black diagonal line with rounded ends:
auto line = MakeObject<Shape>(doc, ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(EndCap::Round);
builder->InsertNode(line);
// 3 - Arrow with a green fill:
auto filledInArrow = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_ForeColor(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_Visible(true);
builder->InsertNode(filledInArrow);
// 4 - Arrow with a flipped orientation filled in with the Aspose logo:
auto filledInArrowImg = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = System::IO::File::ReadAllBytes(ImageDir + u"Logo.jpg");
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flip the orientation of our arrow, we also flip the image that the arrow contains.
// Flip the image the other way to cancel this out before getting the shape to display it.
image->RotateFlip(System::Drawing::RotateFlipType::RotateNoneFlipXY);
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");
Enumerator
None 

The line does not have an arrow at the end.

Arrow 

The arrow is a solid triangle.

Stealth 

The arrow is a "stealth" arrow.

Diamond 

The line end is a solid diamond.

Oval 

The line end is a solid oval.

Open 

The arrow is an open arrow.

Default 

Same as None.

◆ ArrowWidth

Width of the arrow at the end of a line.

See also
Aspose::Words::Drawing::Stroke::get_StartArrowWidth
Aspose::Words::Drawing::Stroke::get_EndArrowWidth
Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are four examples of shapes that we can insert into our documents.
// 1 - Dotted, horizontal, half-transparent red line
// with an arrow on the left end and a diamond on the right end:
auto arrow = MakeObject<Shape>(doc, ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// 2 - Thick black diagonal line with rounded ends:
auto line = MakeObject<Shape>(doc, ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(EndCap::Round);
builder->InsertNode(line);
// 3 - Arrow with a green fill:
auto filledInArrow = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_ForeColor(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_Visible(true);
builder->InsertNode(filledInArrow);
// 4 - Arrow with a flipped orientation filled in with the Aspose logo:
auto filledInArrowImg = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = System::IO::File::ReadAllBytes(ImageDir + u"Logo.jpg");
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flip the orientation of our arrow, we also flip the image that the arrow contains.
// Flip the image the other way to cancel this out before getting the shape to display it.
image->RotateFlip(System::Drawing::RotateFlipType::RotateNoneFlipXY);
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");
Enumerator
Narrow 
Medium 
Wide 
Default 

Same as Narrow.

◆ DashStyle

Dashed line style.

See also
Aspose::Words::Drawing::Stroke::get_DashStyle
Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are four examples of shapes that we can insert into our documents.
// 1 - Dotted, horizontal, half-transparent red line
// with an arrow on the left end and a diamond on the right end:
auto arrow = MakeObject<Shape>(doc, ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// 2 - Thick black diagonal line with rounded ends:
auto line = MakeObject<Shape>(doc, ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(EndCap::Round);
builder->InsertNode(line);
// 3 - Arrow with a green fill:
auto filledInArrow = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_ForeColor(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_Visible(true);
builder->InsertNode(filledInArrow);
// 4 - Arrow with a flipped orientation filled in with the Aspose logo:
auto filledInArrowImg = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = System::IO::File::ReadAllBytes(ImageDir + u"Logo.jpg");
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flip the orientation of our arrow, we also flip the image that the arrow contains.
// Flip the image the other way to cancel this out before getting the shape to display it.
image->RotateFlip(System::Drawing::RotateFlipType::RotateNoneFlipXY);
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");
Enumerator
Solid 

Solid (continuous) pen.

ShortDash 

System dash style.

ShortDot 

System dash style.

ShortDashDot 

System dash style.

ShortDashDotDot 

System dash style.

Dot 

Square dot style.

Dash 

Dash style.

LongDash 

Long dash style.

DashDot 

Dash short dash.

LongDashDot 

Long dash short dash.

LongDashDotDot 

Long dash short dash short dash.

Default 

Same as Solid.

◆ EndCap

Specifies line cap style.

See also
Aspose::Words::Drawing::Stroke::get_EndCap
Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are four examples of shapes that we can insert into our documents.
// 1 - Dotted, horizontal, half-transparent red line
// with an arrow on the left end and a diamond on the right end:
auto arrow = MakeObject<Shape>(doc, ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// 2 - Thick black diagonal line with rounded ends:
auto line = MakeObject<Shape>(doc, ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(EndCap::Round);
builder->InsertNode(line);
// 3 - Arrow with a green fill:
auto filledInArrow = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_ForeColor(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_Visible(true);
builder->InsertNode(filledInArrow);
// 4 - Arrow with a flipped orientation filled in with the Aspose logo:
auto filledInArrowImg = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = System::IO::File::ReadAllBytes(ImageDir + u"Logo.jpg");
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flip the orientation of our arrow, we also flip the image that the arrow contains.
// Flip the image the other way to cancel this out before getting the shape to display it.
image->RotateFlip(System::Drawing::RotateFlipType::RotateNoneFlipXY);
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");
Enumerator
Round 

Rounded ends.

Square 

Square protrudes by half line width.

Flat 

Line ends at end point.

Default 

Default value is Flat.

◆ FillType

Specifies fill type for a fillable object.

Enumerator
Solid 

Solid fill.

Patterned 

Patterned fill.

Gradient 

Gradient fill.

Textured 

Textured fill.

Background 

Fill is the same as the background.

Picture 

Picture fill.

◆ FlipOrientation

Possible values for the orientation of a shape.

See also
Aspose::Words::Drawing::ShapeBase::get_FlipOrientation
Examples

Shows how to flip a shape on an axis.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert an image shape and leave its orientation in its default state.
100, 100, 100, WrapType::None);
shape->get_ImageData()->SetImage(ImageDir + u"Logo.jpg");
ASSERT_EQ(FlipOrientation::None, shape->get_FlipOrientation());
shape->get_ImageData()->SetImage(ImageDir + u"Logo.jpg");
// Set the "FlipOrientation" property to "FlipOrientation.Horizontal" to flip the second shape on the y-axis,
// making it into a horizontal mirror image of the first shape.
shape->set_FlipOrientation(FlipOrientation::Horizontal);
shape->get_ImageData()->SetImage(ImageDir + u"Logo.jpg");
// Set the "FlipOrientation" property to "FlipOrientation.Horizontal" to flip the third shape on the x-axis,
// making it into a vertical mirror image of the first shape.
shape->set_FlipOrientation(FlipOrientation::Vertical);
shape->get_ImageData()->SetImage(ImageDir + u"Logo.jpg");
// Set the "FlipOrientation" property to "FlipOrientation.Horizontal" to flip the fourth shape on both the x and y axes,
// making it into a horizontal and vertical mirror image of the first shape.
shape->set_FlipOrientation(FlipOrientation::Both);
doc->Save(ArtifactsDir + u"Shape.FlipShapeOrientation.docx");
Enumerator
None 

Coordinates are not flipped.

Horizontal 

Flip along the y-axis, reversing the x-coordinates.

Vertical 

Flip along the x-axis, reversing the y-coordinates.

Both 

Flip along both the y- and x-axis.

◆ HorizontalAlignment

Specifies horizontal alignment of a floating shape, text frame or floating table.

See also
Aspose::Words::Drawing::ShapeBase::get_HorizontalAlignment
Examples

Shows how to insert a floating image to the center of a page.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a floating image that will appear behind the overlapping text and align it to the page's center.
SharedPtr<Shape> shape = builder->InsertImage(ImageDir + u"Logo.jpg");
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_HorizontalAlignment(HorizontalAlignment::Center);
shape->set_VerticalAlignment(VerticalAlignment::Center);
doc->Save(ArtifactsDir + u"Image.CreateFloatingPageCenter.docx");
Enumerator
None 

The object is explicitly positioned, usually using its Left property.

Default 

Same as None.

Left 

Specifies that the object shall be left aligned to the horizontal alignment base.

Center 

Specifies that the object shall be centered with respect to the horizontal alignment base.

Right 

Specifies that the object shall be right aligned to the horizontal alignment base.

Inside 

Specifies that the object shall be inside of the horizontal alignment base.

Outside 

Specifies that the object shall be outside of the horizontal alignment base.

◆ HorizontalRuleAlignment

Represents the alignment for the specified horizontal rule.

Enumerator
Left 

Aligned to the left.

Center 

Aligned to the center.

Right 

Aligned to the right.

◆ ImageType

Specifies the type (format) of an image in a Microsoft Word document.

See also
Aspose::Words::Drawing::ImageData::get_ImageType
Examples

Shows how to add an image to a shape and check its type.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = System::IO::File::ReadAllBytes(ImageDir + u"Logo.jpg");
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// The image in the URL is a .gif. Inserting it into a document converts it into a .png.
SharedPtr<Shape> imgShape = builder->InsertImage(image);
ASSERT_EQ(ImageType::Jpeg, imgShape->get_ImageData()->get_ImageType());
}
}
Enumerator
NoImage 

The is no image data.

Unknown 

An unknown image type or image type that cannot be directly stored inside a Microsoft Word document.

Emf 

Windows Enhanced Metafile.

Wmf 

Windows Metafile.

Pict 

Macintosh PICT. An existing image will be preserved in a document, but inserting new PICT images into a document is not supported.

Jpeg 

JPEG JFIF.

Png 

Portable Network Graphics.

Bmp 

Windows Bitmap.

◆ JoinStyle

Line join style.

See also
Aspose::Words::Drawing::Stroke::get_JoinStyle
Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are four examples of shapes that we can insert into our documents.
// 1 - Dotted, horizontal, half-transparent red line
// with an arrow on the left end and a diamond on the right end:
auto arrow = MakeObject<Shape>(doc, ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// 2 - Thick black diagonal line with rounded ends:
auto line = MakeObject<Shape>(doc, ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(EndCap::Round);
builder->InsertNode(line);
// 3 - Arrow with a green fill:
auto filledInArrow = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_ForeColor(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_Visible(true);
builder->InsertNode(filledInArrow);
// 4 - Arrow with a flipped orientation filled in with the Aspose logo:
auto filledInArrowImg = MakeObject<Shape>(doc, ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = System::IO::File::ReadAllBytes(ImageDir + u"Logo.jpg");
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flip the orientation of our arrow, we also flip the image that the arrow contains.
// Flip the image the other way to cancel this out before getting the shape to display it.
image->RotateFlip(System::Drawing::RotateFlipType::RotateNoneFlipXY);
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");
Enumerator
Bevel 

Join edges by a straight line.

Miter 

Extend edges until they join.

Round 

Draw an arc between the two edges.

◆ LayoutFlow

Determines the flow of the text layout in a textbox.

See also
Aspose::Words::Drawing::TextBox::get_LayoutFlow
Examples

Shows how to add text to a text box, and change its orientation

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto textbox = MakeObject<Shape>(doc, ShapeType::TextBox);
textbox->set_Width(100);
textbox->set_Height(100);
textbox->get_TextBox()->set_LayoutFlow(LayoutFlow::BottomToTop);
textbox->AppendChild(MakeObject<Paragraph>(doc));
builder->InsertNode(textbox);
builder->MoveTo(textbox->get_FirstParagraph());
builder->Write(u"This text is flipped 90 degrees to the left.");
doc->Save(ArtifactsDir + u"Drawing.TextBox.docx");
Enumerator
Horizontal 

Text is displayed horizontally.

TopToBottomIdeographic 

Ideographic text is displayed vertically.

BottomToTop 

Text is displayed vertically.

TopToBottom 

Text is displayed vertically.

HorizontalIdeographic 

Ideographic text is displayed horizontally.

Vertical 

Text is displayed vertically.

◆ PresetTexture

Specifies texture to be used to fill a shape.

Enumerator
None 

No Texture.

BlueTissuePaper 

Blue tissue paper texture.

Bouquet 

Bouquet texture.

BrownMarble 

Brown marble texture.

Canvas 

Canvas texture.

Cork 

Cork texture.

Denim 

Denim texture.

FishFossil 

Fish fossil texture.

Granite 

Granite texture.

GreenMarble 

Green marble texture.

MediumWood 

Medium wood texture.

Newsprint 

Newsprint texture.

Oak 

Oak texture.

PaperBag 

Paper bag texture.

Papyrus 

Papyrus texture.

Parchment 

Parchment texture.

PinkTissuePaper 

Pink tissue paper texture.

PurpleMesh 

Purple mesh texture.

RecycledPaper 

Recycled paper texture.

Sand 

Sand texture.

Stationery 

Stationery texture.

Walnut 

Walnut texture.

WaterDroplets 

Water droplets texture.

WhiteMarble 

White marble texture.

WovenMat 

Woven mat texture.

◆ RelativeHorizontalPosition

Specifies to what the horizontal position of a shape or text frame is relative.

See also
Aspose::Words::Drawing::ShapeBase::get_RelativeHorizontalPosition
Examples

Shows how to insert an image, and use it as a watermark.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert the image into the header so that it will be visible on every page.
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromFile(ImageDir + u"Transparent background logo.png");
builder->MoveToHeaderFooter(HeaderFooterType::HeaderPrimary);
SharedPtr<Shape> shape = builder->InsertImage(image);
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
// Place the image at the center of the page.
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_Left((builder->get_PageSetup()->get_PageWidth() - shape->get_Width()) / 2);
shape->set_Top((builder->get_PageSetup()->get_PageHeight() - shape->get_Height()) / 2);
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertWatermark.docx");

Shows how to insert a floating image to the center of a page.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a floating image that will appear behind the overlapping text and align it to the page's center.
SharedPtr<Shape> shape = builder->InsertImage(ImageDir + u"Logo.jpg");
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_HorizontalAlignment(HorizontalAlignment::Center);
shape->set_VerticalAlignment(VerticalAlignment::Center);
doc->Save(ArtifactsDir + u"Image.CreateFloatingPageCenter.docx");
Enumerator
Margin 

Specifies that the horizontal positioning shall be relative to the page margins.

Page 

The object is positioned relative to the left edge of the page.

Column 

The object is positioned relative to the left side of the column.

Character 

The object is positioned relative to the left side of the paragraph.

LeftMargin 

Specifies that the horizontal positioning shall be relative to the left margin of the page.

RightMargin 

Specifies that the horizontal positioning shall be relative to the right margin of the page.

InsideMargin 

Specifies that the horizontal positioning shall be relative to the inside margin of the current page (the left margin on odd pages, right on even pages).

OutsideMargin 

Specifies that the horizontal positioning shall be relative to the outside margin of the current page (the right margin on odd pages, left on even pages).

Default 

Default value is Column.

◆ RelativeVerticalPosition

Specifies to what the vertical position of a shape or text frame is relative.

See also
Aspose::Words::Drawing::ShapeBase::get_RelativeVerticalPosition
Examples

Shows how to insert an image, and use it as a watermark.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert the image into the header so that it will be visible on every page.
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromFile(ImageDir + u"Transparent background logo.png");
builder->MoveToHeaderFooter(HeaderFooterType::HeaderPrimary);
SharedPtr<Shape> shape = builder->InsertImage(image);
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
// Place the image at the center of the page.
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_Left((builder->get_PageSetup()->get_PageWidth() - shape->get_Width()) / 2);
shape->set_Top((builder->get_PageSetup()->get_PageHeight() - shape->get_Height()) / 2);
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertWatermark.docx");

Shows how to insert a floating image to the center of a page.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a floating image that will appear behind the overlapping text and align it to the page's center.
SharedPtr<Shape> shape = builder->InsertImage(ImageDir + u"Logo.jpg");
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_HorizontalAlignment(HorizontalAlignment::Center);
shape->set_VerticalAlignment(VerticalAlignment::Center);
doc->Save(ArtifactsDir + u"Image.CreateFloatingPageCenter.docx");
Enumerator
Margin 

Specifies that the vertical positioning shall be relative to the page margins.

Page 

The object is positioned relative to the top edge of the page.

Paragraph 

The object is positioned relative to the top of the paragraph that contains the anchor.

Line 

Undocumented.

TopMargin 

Specifies that the vertical positioning shall be relative to the top margin of the current page.

BottomMargin 

Specifies that the vertical positioning shall be relative to the bottom margin of the current page.

InsideMargin 

Specifies that the vertical positioning shall be relative to the inside margin of the current page.

OutsideMargin 

Specifies that the vertical positioning shall be relative to the outside margin of the current page.

TableDefault 

Default value is Margin.

TextFrameDefault 

Default value is Paragraph.

◆ ShapeLineStyle

Specifies the compound line style of a Shape.

See also
Aspose::Words::Drawing::Stroke::get_LineStyle
Examples

Shows how change stroke properties.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
100, 200, 200, WrapType::None);
// Basic shapes, such as the rectangle, have two visible parts.
// 1 - The fill, which applies to the area within the outline of the shape:
shape->get_Fill()->set_ForeColor(System::Drawing::Color::get_White());
// 2 - The stroke, which marks the outline of the shape:
// Modify various properties of this shape's stroke.
SharedPtr<Stroke> stroke = shape->get_Stroke();
stroke->set_On(true);
stroke->set_Weight(5);
stroke->set_Color(System::Drawing::Color::get_Red());
stroke->set_DashStyle(DashStyle::ShortDashDotDot);
stroke->set_JoinStyle(JoinStyle::Miter);
stroke->set_EndCap(EndCap::Square);
stroke->set_LineStyle(ShapeLineStyle::Triple);
doc->Save(ArtifactsDir + u"Shape.Stroke.docx");
Enumerator
Single 

Single line.

Double 

Double lines of equal width.

ThickThin 

Double lines, one thick, one thin.

ThinThick 

Double lines, one thin, one thick.

Triple 

Three lines, thin, thick, thin.

Default 

Default value is Single.

◆ ShapeMarkupLanguage

Specifies Markup language used for the shape.

Examples

Shows how to set an OOXML compliance specification for a saved document to adhere to.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc->get_CompatibilityOptions()->OptimizeFor(MsWordVersion::Word2003);
builder->InsertImage(ImageDir + u"Transparent background logo.png");
ASSERT_EQ(ShapeMarkupLanguage::Vml, (System::DynamicCast<Shape>(doc->GetChild(NodeType::Shape, 0, true)))->get_MarkupLanguage());
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_Compliance(OoxmlCompliance::Iso29500_2008_Strict);
saveOptions->set_SaveFormat(SaveFormat::Docx);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx");
ASSERT_EQ(ShapeMarkupLanguage::Dml, (System::DynamicCast<Shape>(doc->GetChild(NodeType::Shape, 0, true)))->get_MarkupLanguage());
Enumerator
Dml 

Drawing Markup Language is used to define the shape.

Vml 

Vector Markup Language is used to define the shape.

◆ ShapeType

Specifies the type of shape in a Microsoft Word document.

See also
Aspose::Words::Drawing::ShapeBase::get_ShapeType
Examples

Shows how to insert a shape with an image from the local file system into a document.

auto doc = MakeObject<Document>();
// The "Shape" class's public constructor will create a shape with "ShapeMarkupLanguage.Vml" markup type.
// If you need to create a shape of a non-primitive type, such as SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, or DiagonalCornersRounded,
// please use DocumentBuilder.InsertShape.
auto shape = MakeObject<Shape>(doc, ShapeType::Image);
shape->get_ImageData()->SetImage(ImageDir + u"Windows MetaFile.wmf");
shape->set_Width(100);
shape->set_Height(100);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(shape);
doc->Save(ArtifactsDir + u"Image.FromFile.docx");
Enumerator
Image 

The shape is an image.

TextBox 

The shape is a textbox. Note that shapes of many other types can also have text inside them too. A shape does not have to have this type to contain text.

Group 

The shape is a group shape.

OleObject 

The shape is an OLE object. You cannot create shapes of this type in the document.

OleControl 

The shape is an ActiveX control. You cannot create shapes of this type in the document.

NonPrimitive 

A shape drawn by user and consisting of multiple segments and/or vertices (curve, freeform or scribble). You cannot create shapes of this type in the document.

Rectangle 
RoundRectangle 
Ellipse 
Diamond 
Triangle 
RightTriangle 
Parallelogram 
Trapezoid 
Hexagon 
Octagon 
Plus 
Star 
Arrow 
ThickArrow 
HomePlate 
Cube 
Balloon 
Seal 
Arc 
Line 
Plaque 
Can 
Donut 
TextSimple 
TextOctagon 
TextHexagon 
TextCurve 
TextWave 
TextRing 
TextOnCurve 
TextOnRing 
StraightConnector1 
BentConnector2 
BentConnector3 
BentConnector4 
BentConnector5 
CurvedConnector2 
CurvedConnector3 
CurvedConnector4 
CurvedConnector5 
Callout1 
Callout2 
Callout3 
AccentCallout1 
AccentCallout2 
AccentCallout3 
BorderCallout1 
BorderCallout2 
BorderCallout3 
AccentBorderCallout1 
AccentBorderCallout2 
AccentBorderCallout3 
Ribbon 
Ribbon2 
Chevron 
Pentagon 
NoSmoking 
Seal8 
Seal16 
Seal32 
WedgeRectCallout 
WedgeRRectCallout 
WedgeEllipseCallout 
Wave 
FoldedCorner 
LeftArrow 
DownArrow 
UpArrow 
LeftRightArrow 
UpDownArrow 
IrregularSeal1 
IrregularSeal2 
LightningBolt 
Heart 
QuadArrow 
LeftArrowCallout 
RightArrowCallout 
UpArrowCallout 
DownArrowCallout 
LeftRightArrowCallout 
UpDownArrowCallout 
QuadArrowCallout 
Bevel 
LeftBracket 
RightBracket 
LeftBrace 
RightBrace 
LeftUpArrow 
BentUpArrow 
BentArrow 
Seal24 
StripedRightArrow 
NotchedRightArrow 
BlockArc 
SmileyFace 
VerticalScroll 
HorizontalScroll 
CircularArrow 
CustomShape 

This shape type seems to be set for shapes that are not part of the standard set of the auto shapes in Microsoft Word. For example, if you insert a new auto shape from ClipArt. You cannot create shapes of this type in the document.

UturnArrow 
CurvedRightArrow 
CurvedLeftArrow 
CurvedUpArrow 
CurvedDownArrow 
CloudCallout 
EllipseRibbon 
EllipseRibbon2 
FlowChartProcess 
FlowChartDecision 
FlowChartInputOutput 
FlowChartPredefinedProcess 
FlowChartInternalStorage 
FlowChartDocument 
FlowChartMultidocument 
FlowChartTerminator 
FlowChartPreparation 
FlowChartManualInput 
FlowChartManualOperation 
FlowChartConnector 
FlowChartPunchedCard 
FlowChartPunchedTape 
FlowChartSummingJunction 
FlowChartOr 
FlowChartCollate 
FlowChartSort 
FlowChartExtract 
FlowChartMerge 
FlowChartOfflineStorage 
FlowChartOnlineStorage 
FlowChartMagneticTape 
FlowChartMagneticDisk 
FlowChartMagneticDrum 
FlowChartDisplay 
FlowChartDelay 
TextPlainText 

WordArt object.

TextStop 

WordArt object.

TextTriangle 

WordArt object.

TextTriangleInverted 

WordArt object.

TextChevron 

WordArt object.

TextChevronInverted 

WordArt object.

TextRingInside 

WordArt object.

TextRingOutside 

WordArt object.

TextArchUpCurve 

WordArt object.

TextArchDownCurve 

WordArt object.

TextCircleCurve 

WordArt object.

TextButtonCurve 

WordArt object.

TextArchUpPour 

WordArt object.

TextArchDownPour 

WordArt object.

TextCirclePour 

WordArt object.

TextButtonPour 

WordArt object.

TextCurveUp 

WordArt object.

TextCurveDown 

WordArt object.

TextCascadeUp 

WordArt object.

TextCascadeDown 

WordArt object.

TextWave1 

WordArt object.

TextWave2 

WordArt object.

TextWave3 

WordArt object.

TextWave4 

WordArt object.

TextInflate 

WordArt object.

TextDeflate 

WordArt object.

TextInflateBottom 

WordArt object.

TextDeflateBottom 

WordArt object.

TextInflateTop 

WordArt object.

TextDeflateTop 

WordArt object.

TextDeflateInflate 

WordArt object.

TextDeflateInflateDeflate 

WordArt object.

TextFadeRight 

WordArt object.

TextFadeLeft 

WordArt object.

TextFadeUp 

WordArt object.

TextFadeDown 

WordArt object.

TextSlantUp 

WordArt object.

TextSlantDown 

WordArt object.

TextCanUp 

WordArt object.

TextCanDown 

WordArt object.

FlowChartAlternateProcess 
FlowChartOffpageConnector 
Callout90 
AccentCallout90 
BorderCallout90 
AccentBorderCallout90 
LeftRightUpArrow 
Sun 
Moon 
BracketPair 
BracePair 
Seal4 
DoubleWave 
ActionButtonBlank 
ActionButtonHome 
ActionButtonHelp 
ActionButtonInformation 
ActionButtonForwardNext 
ActionButtonBackPrevious 
ActionButtonEnd 
ActionButtonBeginning 
ActionButtonReturn 
ActionButtonDocument 
ActionButtonSound 
ActionButtonMovie 
SingleCornerSnipped 

Snip single corner rectangle object.

TopCornersSnipped 

Snip same side corner rectangle.

DiagonalCornersSnipped 

Snip diagonal corner rectangle.

TopCornersOneRoundedOneSnipped 

Snip and round single corner rectangle.

SingleCornerRounded 

Round single corner rectangle.

TopCornersRounded 

Round same side corner rectangle.

DiagonalCornersRounded 

Round diagonal corner rectangle.

Heptagon 

Heptagon.

Cloud 

Cloud.

Seal6 

Six-pointed star.

Seal7 

Seven-pointed star.

Seal10 

Ten-pointed star.

Seal12 

Twelve-pointed star.

SwooshArrow 

Swoosh arrow.

Teardrop 

Teardrop.

SquareTabs 

Square tabs.

PlaqueTabs 

Plaque tabs.

Pie 

Pie.

WedgePie 

Wedge pie.

InverseLine 

Inverse line.

MathPlus 

Math plus.

MathMinus 

Math minus.

MathMultiply 

Math multiply.

MathDivide 

Math divide.

MathEqual 

Math equal.

MathNotEqual 

Math not equal.

NonIsoscelesTrapezoid 

Non-isosceles trapezoid.

LeftRightCircularArrow 

Left-right circular arrow.

LeftRightRibbon 

Left-right ribbon.

LeftCircularArrow 

Left circular arrow.

Frame 

Frame.

HalfFrame 

Half frame.

Funnel 

Funnel.

Gear6 

Six-tooth gear.

Gear9 

Nine-tooth gear.

Decagon 

Decagon.

Dodecagon 

Dodecagon.

DiagonalStripe 

Diagonal stripe.

Corner 

Corner.

CornerTabs 

Corner tabs.

Chord 

Chord.

ChartPlus 

Chart plus.

ChartStar 

Chart star.

ChartX 

Chart X.

MinValue 

Reserved for the system use.

◆ TextBoxAnchor

Specifies values used for shape text vertical alignment.

Examples

Shows how to vertically align the text contents of a text box.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertShape(ShapeType::TextBox, 200, 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->get_TextBox()->set_VerticalAnchor(verticalAnchor);
builder->MoveTo(shape->get_FirstParagraph());
builder->Write(u"Hello world!");
// The vertical aligning of text inside text boxes is available from Microsoft Word 2007 onwards.
doc->get_CompatibilityOptions()->OptimizeFor(MsWordVersion::Word2007);
doc->Save(ArtifactsDir + u"Shape.VerticalAnchor.docx");
Enumerator
Top 

Text is aligned to the top of the textbox.

Middle 

Text is aligned to the middle of the textbox.

Bottom 

Text is aligned to the bottom of the textbox.

TopCentered 

Text is aligned to the top centered of the textbox.

MiddleCentered 

Text is aligned to the middle centered of the textbox.

BottomCentered 

Text is aligned to the bottom centered of the textbox.

TopBaseline 

Text is aligned to the top baseline of the textbox.

BottomBaseline 

Text is aligned to the bottom baseline of the textbox.

TopCenteredBaseline 

Text is aligned to the top centered baseline of the textbox.

BottomCenteredBaseline 

Text is aligned to the bottom centered baseline of the textbox.

◆ TextBoxWrapMode

Specifies how text wraps inside a shape.

Examples

Shows how to set a wrapping mode for the contents of a text box.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> textBoxShape = builder->InsertShape(ShapeType::TextBox, 300, 300);
SharedPtr<TextBox> textBox = textBoxShape->get_TextBox();
// Set the "TextBoxWrapMode" property to "TextBoxWrapMode.None" to increase the text box's width
// to accommodate text, should it be large enough.
// Set the "TextBoxWrapMode" property to "TextBoxWrapMode.Square" to
// wrap all text inside the text box, preserving its dimensions.
textBox->set_TextBoxWrapMode(textBoxWrapMode);
builder->MoveTo(textBoxShape->get_LastParagraph());
builder->get_Font()->set_Size(32);
builder->Write(u"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
doc->Save(ArtifactsDir + u"Shape.TextBoxContentsWrapMode.docx");
Enumerator
Square 

Text wraps inside a shape.

None 

Text does not wrap inside a shape.

◆ TextPathAlignment

WordArt alignment.

See also
Aspose::Words::Drawing::TextPath::get_TextPathAlignment
Examples

Shows how to work with WordArt.

void InsertTextPaths()
{
auto doc = MakeObject<Document>();
// Insert a WordArt object to display text in a shape that we can re-size and move by using the mouse in Microsoft Word.
// Provide a "ShapeType" as an argument to set a shape for the WordArt.
SharedPtr<Shape> shape = AppendWordArt(doc, u"Hello World! This text is bold, and italic.", u"Arial", 480, 24, System::Drawing::Color::get_White(),
// Apply the "Bold' and "Italic" formatting settings to the text using the respective properties.
shape->get_TextPath()->set_Bold(true);
shape->get_TextPath()->set_Italic(true);
// Below are various other text formatting-related properties.
ASSERT_FALSE(shape->get_TextPath()->get_Underline());
ASSERT_FALSE(shape->get_TextPath()->get_Shadow());
ASSERT_FALSE(shape->get_TextPath()->get_StrikeThrough());
ASSERT_FALSE(shape->get_TextPath()->get_ReverseRows());
ASSERT_FALSE(shape->get_TextPath()->get_XScale());
ASSERT_FALSE(shape->get_TextPath()->get_Trim());
ASSERT_FALSE(shape->get_TextPath()->get_SmallCaps());
ASPOSE_ASSERT_EQ(36.0, shape->get_TextPath()->get_Size());
ASSERT_EQ(u"Hello World! This text is bold, and italic.", shape->get_TextPath()->get_Text());
ASSERT_EQ(ShapeType::TextPlainText, shape->get_ShapeType());
// Use the "On" property to show/hide the text.
shape = AppendWordArt(doc, u"On set to \"true\"", u"Calibri", 150, 24, System::Drawing::Color::get_Yellow(), System::Drawing::Color::get_Red(),
shape->get_TextPath()->set_On(true);
shape = AppendWordArt(doc, u"On set to \"false\"", u"Calibri", 150, 24, System::Drawing::Color::get_Yellow(), System::Drawing::Color::get_Purple(),
shape->get_TextPath()->set_On(false);
// Use the "Kerning" property to enable/disable kerning spacing between certain characters.
shape = AppendWordArt(doc, u"Kerning: VAV", u"Times New Roman", 90, 24, System::Drawing::Color::get_Orange(), System::Drawing::Color::get_Red(),
shape->get_TextPath()->set_Kerning(true);
shape = AppendWordArt(doc, u"No kerning: VAV", u"Times New Roman", 100, 24, System::Drawing::Color::get_Orange(), System::Drawing::Color::get_Red(),
shape->get_TextPath()->set_Kerning(false);
// Use the "Spacing" property to set the custom spacing between characters on a scale from 0.0 (none) to 1.0 (default).
shape = AppendWordArt(doc, u"Spacing set to 0.1", u"Calibri", 120, 24, System::Drawing::Color::get_BlueViolet(), System::Drawing::Color::get_Blue(),
shape->get_TextPath()->set_Spacing(0.1);
// Set the "RotateLetters" property to "true" to rotate each character 90 degrees counterclockwise.
shape = AppendWordArt(doc, u"RotateLetters", u"Calibri", 200, 36, System::Drawing::Color::get_GreenYellow(), System::Drawing::Color::get_Green(),
shape->get_TextPath()->set_RotateLetters(true);
// Set the "SameLetterHeights" property to "true" to get the x-height of each character to equal the cap height.
shape = AppendWordArt(doc, u"Same character height for lower and UPPER case", u"Calibri", 300, 24, System::Drawing::Color::get_DeepSkyBlue(),
shape->get_TextPath()->set_SameLetterHeights(true);
// By default, the text's size will always scale to fit the containing shape's size, overriding the text size setting.
shape = AppendWordArt(doc, u"FitShape on", u"Calibri", 160, 24, System::Drawing::Color::get_LightBlue(), System::Drawing::Color::get_Blue(),
ASSERT_TRUE(shape->get_TextPath()->get_FitShape());
shape->get_TextPath()->set_Size(24.0);
// If we set the "FitShape: property to "false", the text will keep the size
// which the "Size" property specifies regardless of the size of the shape.
// Use the "TextPathAlignment" property also to align the text to a side of the shape.
shape = AppendWordArt(doc, u"FitShape off", u"Calibri", 160, 24, System::Drawing::Color::get_LightBlue(), System::Drawing::Color::get_Blue(),
shape->get_TextPath()->set_FitShape(false);
shape->get_TextPath()->set_Size(24.0);
shape->get_TextPath()->set_TextPathAlignment(TextPathAlignment::Right);
doc->Save(ArtifactsDir + u"Shape.InsertTextPaths.docx");
}
static SharedPtr<Shape> AppendWordArt(SharedPtr<Document> doc, String text, String textFontFamily, double shapeWidth, double shapeHeight,
System::Drawing::Color wordArtFill, System::Drawing::Color line, ShapeType wordArtShapeType)
{
// Create an inline Shape, which will serve as a container for our WordArt.
// The shape can only be a valid WordArt shape if we assign a WordArt-designated ShapeType to it.
// These types will have "WordArt object" in the description,
// and their enumerator constant names will all start with "Text".
auto shape = MakeObject<Shape>(doc, wordArtShapeType);
shape->set_WrapType(WrapType::Inline);
shape->set_Width(shapeWidth);
shape->set_Height(shapeHeight);
shape->set_FillColor(wordArtFill);
shape->set_StrokeColor(line);
shape->get_TextPath()->set_Text(text);
shape->get_TextPath()->set_FontFamily(textFontFamily);
auto para = System::DynamicCast<Paragraph>(doc->get_FirstSection()->get_Body()->AppendChild(MakeObject<Paragraph>(doc)));
para->AppendChild(shape);
return shape;
}
Enumerator
Stretch 

Stretch each line of text to fit width.

Center 

Center text on width.

Left 

Left justify.

Right 

Right justify.

LetterJustify 

Spread letters out to fit width.

WordJustify 

Spread words out to fit width.

◆ VerticalAlignment

Specifies vertical alignment of a floating shape, text frame or a floating table.

See also
Aspose::Words::Drawing::ShapeBase::get_VerticalAlignment
Examples

Shows how to insert a floating image to the center of a page.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a floating image that will appear behind the overlapping text and align it to the page's center.
SharedPtr<Shape> shape = builder->InsertImage(ImageDir + u"Logo.jpg");
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_HorizontalAlignment(HorizontalAlignment::Center);
shape->set_VerticalAlignment(VerticalAlignment::Center);
doc->Save(ArtifactsDir + u"Image.CreateFloatingPageCenter.docx");
Enumerator
None 

The object is explicitly positioned, usually using its Top property.

Top 

Specifies that the object shall be at the top of the vertical alignment base.

Center 

Specifies that the object shall be centered with respect to the vertical alignment base.

Bottom 

Specifies that the object shall be at the bottom of the vertical alignment base.

Inside 

Specifies that the object shall be inside of the horizontal alignment base.

Outside 

Specifies that the object shall be outside of the vertical alignment base.

Inline 

Not documented. Seems to be a possible value for floating paragraphs and tables.

Default 

Same as None.

◆ WrapSide

Specifies what side(s) of the shape or picture the text wraps around.

See also
Aspose::Words::Drawing::ShapeBase::get_WrapSide
Examples

Shows how to replace all textbox shapes with image shapes.

auto doc = MakeObject<Document>(MyDir + u"Textboxes in drawing canvas.docx");
ArrayPtr<SharedPtr<Shape>> shapes = doc->GetChildNodes(NodeType::Shape, true)->LINQ_OfType<SharedPtr<Shape>>()->LINQ_ToArray();
auto isTextBox = [](SharedPtr<Shape> s)
{
return s->get_ShapeType() == ShapeType::TextBox;
};
auto isImage = [](SharedPtr<Shape> s)
{
return s->get_ShapeType() == ShapeType::Image;
};
ASSERT_EQ(3, shapes->LINQ_Count(isTextBox));
ASSERT_EQ(1, shapes->LINQ_Count(isImage));
for (SharedPtr<Shape> shape : shapes)
{
if (shape->get_ShapeType() == ShapeType::TextBox)
{
auto replacementShape = MakeObject<Shape>(doc, ShapeType::Image);
replacementShape->get_ImageData()->SetImage(ImageDir + u"Logo.jpg");
replacementShape->set_Left(shape->get_Left());
replacementShape->set_Top(shape->get_Top());
replacementShape->set_Width(shape->get_Width());
replacementShape->set_Height(shape->get_Height());
replacementShape->set_RelativeHorizontalPosition(shape->get_RelativeHorizontalPosition());
replacementShape->set_RelativeVerticalPosition(shape->get_RelativeVerticalPosition());
replacementShape->set_HorizontalAlignment(shape->get_HorizontalAlignment());
replacementShape->set_VerticalAlignment(shape->get_VerticalAlignment());
replacementShape->set_WrapType(shape->get_WrapType());
replacementShape->set_WrapSide(shape->get_WrapSide());
shape->get_ParentNode()->InsertAfter(replacementShape, shape);
shape->Remove();
}
}
shapes = doc->GetChildNodes(NodeType::Shape, true)->LINQ_OfType<SharedPtr<Shape>>()->LINQ_ToArray();
ASSERT_EQ(0, shapes->LINQ_Count(isTextBox));
ASSERT_EQ(4, shapes->LINQ_Count(isImage));
doc->Save(ArtifactsDir + u"Shape.ReplaceTextboxesWithImages.docx");
Enumerator
Both 

The document text wraps on both sides of the shape.

Left 

The document text wraps on the left side of the shape only. There is a text free area on the right of the shape.

Right 

The document text wraps on the right side of the shape only. There is a text free area on the left side of the shape.

Largest 

The document text wraps on the side of the shape that is farthest from the page margin, leaving text free area on the other side of the shape.

Default 

Default value is Both.

◆ WrapType

Specifies how text is wrapped around a shape or picture.

See also
Aspose::Words::Drawing::ShapeBase::get_WrapType
Examples

Shows how to insert an image, and use it as a watermark.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert the image into the header so that it will be visible on every page.
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromFile(ImageDir + u"Transparent background logo.png");
builder->MoveToHeaderFooter(HeaderFooterType::HeaderPrimary);
SharedPtr<Shape> shape = builder->InsertImage(image);
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
// Place the image at the center of the page.
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_Left((builder->get_PageSetup()->get_PageWidth() - shape->get_Width()) / 2);
shape->set_Top((builder->get_PageSetup()->get_PageHeight() - shape->get_Height()) / 2);
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertWatermark.docx");

Shows how to insert a floating image to the center of a page.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a floating image that will appear behind the overlapping text and align it to the page's center.
SharedPtr<Shape> shape = builder->InsertImage(ImageDir + u"Logo.jpg");
shape->set_WrapType(WrapType::None);
shape->set_BehindText(true);
shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::Page);
shape->set_RelativeVerticalPosition(RelativeVerticalPosition::Page);
shape->set_HorizontalAlignment(HorizontalAlignment::Center);
shape->set_VerticalAlignment(VerticalAlignment::Center);
doc->Save(ArtifactsDir + u"Image.CreateFloatingPageCenter.docx");
Enumerator
None 

No text wrapping around the shape. The shape is placed behind or in front of text.

Inline 

The shape remains on the same layer as text and treated as a character.

TopBottom 

The text stops at the top of the shape and restarts on the line below the shape.

Square 

Wraps text around all sides of the square bounding box of the shape.

Tight 

Wraps tightly around the edges of the shape, instead of wrapping around the bounding box.

Through 

Same as Tight, but wraps inside any parts of the shape that are open.