Aspose::Words::Drawing::RelativeHorizontalSize enum

RelativeHorizontalSize enum

Specifies relatively to what the width of a shape or a text frame is calculated horizontally.

enum class RelativeHorizontalSize : int

Values

NameValueDescription
Default1Default value is Margin.
InnerMargin4Specifies that the width is calculated relatively to the inside margin area size, to the left margin area size for odd pages and to the right margin area size for even pages.
LeftMargin2Specifies that the width is calculated relatively to the left margin area size.
Margin0Specifies that the width is calculated relatively to the space between the left and the right margins.
OuterMargin5Specifies that the width is calculated relatively to the outside margin area size, to the right margin area size for odd pages and to the left margin area size for even pages.
Page1Specifies that the width is calculated relatively to the page width.
RightMargin3Specifies that the width is calculated relatively to the right margin area size.

Examples

Shows how to set relative size and position.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

// Adding a simple shape with absolute size and position.
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertShape(ShapeType::Rectangle, static_cast<double>(100), static_cast<double>(40));
// Set WrapType to WrapType.None since Inline shapes are automatically converted to absolute units.
shape->set_WrapType(WrapType::None);

// Checking and setting the relative horizontal size.
if (shape->get_RelativeHorizontalSize() == RelativeHorizontalSize::Default)
{
    // Setting the horizontal size binding to Margin.
    shape->set_RelativeHorizontalSize(RelativeHorizontalSize::Margin);
    // Setting the width to 50% of Margin width.
    shape->set_WidthRelative(50);
}

// Checking and setting the relative vertical size.
if (shape->get_RelativeVerticalSize() == RelativeVerticalSize::Default)
{
    // Setting the vertical size binding to Margin.
    shape->set_RelativeVerticalSize(RelativeVerticalSize::Margin);
    // Setting the heigh to 30% of Margin height.
    shape->set_HeightRelative(30);
}

// Checking and setting the relative vertical position.
if (shape->get_RelativeVerticalPosition() == RelativeVerticalPosition::Paragraph)
{
    // etting the position binding to TopMargin.
    shape->set_RelativeVerticalPosition(RelativeVerticalPosition::TopMargin);
    // Setting relative Top to 30% of TopMargin position.
    shape->set_TopRelative(30);
}

// Checking and setting the relative horizontal position.
if (shape->get_RelativeHorizontalPosition() == RelativeHorizontalPosition::Default)
{
    // Setting the position binding to RightMargin.
    shape->set_RelativeHorizontalPosition(RelativeHorizontalPosition::RightMargin);
    // The position relative value can be negative.
    shape->set_LeftRelative(-260);
}

doc->Save(get_ArtifactsDir() + u"Shape.RelativeSizeAndPosition.docx");

See Also