Skip to main content

SetRespectBorders

Respects the form border width when scaling the image.

Syntax

expression.SetRespectBorders(isRespect);

expression - A variable that represents a ApiPictureForm class.

Parameters

NameRequired/OptionalData typeDefaultDescription
isRespectOptionalbooleantrueSpecifies if the form border width will be respected (true) or not (false).

Returns

boolean

Example

Prevent an image from overlapping the field border when it is scaled in a document.

// How do I keep a scaled image from overflowing the edges of its picture field in a document?

// Ensure the border of a picture field stays visible no matter how the image is resized in a document.

let doc = Api.GetDocument();
let pictureForm = Api.CreatePictureForm({"key": "Personal information", "tip": "Upload your photo", "required": true, "placeholder": "Photo", "scaleFlag": "tooBig", "lockAspectRatio": true, "shiftX": 50, "shiftY": 50});
let paragraph = doc.GetElement(0);
paragraph.AddElement(pictureForm);
pictureForm.SetImage("https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png", Api.MillimetersToEmus(70), Api.MillimetersToEmus(80));
pictureForm.SetRespectBorders(true);
let respectBorders = pictureForm.IsRespectBorders();
paragraph = Api.CreateParagraph();
paragraph.AddText("The borders of the picture form in this document are respected when scaling the image: " + respectBorders);
doc.Push(paragraph);