Skip to main content

ToFixed

Converts the current form to a fixed size form.

Inherited from ApiFormBase.ToFixed.

Syntax​

expression.ToFixed(width, height, keepPosition);

expression - A variable that represents an ApiPictureForm class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
widthRequiredtwipsThe wrapper shape width measured in twentieths of a point (1/1440 of an inch).
heightRequiredtwipsThe wrapper shape height measured in twentieths of a point (1/1440 of an inch).
keepPositionRequiredbooleanSave position on the page (it can be a little bit slow, because it runs the document calculation).

Returns​

boolean

Example​

Lock a picture field to a specific width and height in a document.

// How do I stop a picture field from changing its dimensions when content is added in a document?

// Freeze the size of a picture field so it never grows or shrinks 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, "respectBorders": false, "shiftX": 50, "shiftY": 50});
pictureForm.SetImage("https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png", Api.MillimetersToEmus(70), Api.MillimetersToEmus(80));
let paragraph = doc.GetElement(0);
paragraph.AddElement(pictureForm);
pictureForm.ToFixed(10 * 240, 10 * 240);
let fixed = pictureForm.IsFixed();
paragraph = Api.CreateParagraph();
paragraph.AddText("The first form from this document has a fixed size: " + fixed);
doc.Push(paragraph);