Skip to main content

SetLockAspectRatio

Locks the aspect ratio of the current picture form.

Syntax

expression.SetLockAspectRatio(isLock);

expression - A variable that represents a ApiPictureForm class.

Parameters

NameRequired/OptionalData typeDefaultDescription
isLockOptionalbooleantrueSpecifies if the aspect ratio of the current picture form will be locked (true) or not (false).

Returns

boolean

Example

Lock the aspect ratio of the picture form.

// How to lock an aspect ratio of the picture form in this document.

// Lock the aspect ratio of the picture form.

let doc = Api.GetDocument();
let pictureForm = Api.CreatePictureForm({"key": "Personal information", "tip": "Upload your photo", "required": true, "placeholder": "Photo", "scaleFlag": "tooBig", "respectBorders": false, "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.SetLockAspectRatio(true);
let lock = pictureForm.IsLockAspectRatio();
paragraph = Api.CreateParagraph();
paragraph.AddText("The aspect ratio of the picture form in this document is locked: " + lock);
doc.Push(paragraph);