跳到主要内容

SetRelativeHeight

Sets the relative height of the object (image, shape, chart) bounding box.

Syntax

expression.SetRelativeHeight(sRelativeFrom, nPercent);

expression - A variable that represents a ApiDrawing class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sRelativeFromOptionalRelFromV"page"The document element which will be taken as a countdown point for the object height.
nPercentRequiredpercentageNo description provided.

Returns

boolean

Example

This example demonstrates relative height shape sizing to page dimensions.

// How to set shape width and height as percentages of the page.

// Create a responsive rectangle that scales with page size.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let fill = Api.CreateSolidFill(Api.CreateRGBColor(91, 155, 213));
let stroke = Api.CreateStroke(0.4 * 36000, Api.CreateSolidFill(Api.CreateRGBColor(65, 113, 156)));
let drawing = Api.CreateShape("rect", 1 * 36000, 1 * 36000, fill, stroke);
drawing.SetWrappingStyle("inFront");
drawing.SetVerPosition("page", 50 * 36000);
drawing.SetHorPosition("page", 0);
drawing.SetRelativeWidth("page", 100);
drawing.SetRelativeHeight("page", 25);
paragraph.AddDrawing(drawing);
paragraph = Api.CreateParagraph();
paragraph.AddText("The shape was created with a width 100% of page width and 25% of height page");
doc.Push(paragraph);