SetPicturePosition
Sets the picture position inside the current form: -0 - the picture is placed on the left/top; -50 - the picture is placed in the center; -100 - the picture is placed on the right/bottom.
Syntax
expression.SetPicturePosition(nShiftX, nShiftY);
expression - A variable that represents a ApiPictureForm class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| nShiftX | Required | percentage | Horizontal position measured in percent. | |
| nShiftY | Required | percentage | Vertical position measured in percent. |
Returns
boolean
Example
This example sets the picture position inside the form.
- Code
- Result
// How to move the picture inside the form.
// Specify the picture position of the form.
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});
let paragraph = doc.GetElement(0);
paragraph.AddElement(pictureForm);
pictureForm.SetImage("https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png");
pictureForm.SetPicturePosition(70, 70);
let position = pictureForm.GetPicturePosition();
paragraph = Api.CreateParagraph();
paragraph.AddText("Picture position: ");
paragraph.AddLineBreak();
for (let i = 0; i < position.length; i++ ){
let shift = position[i];
paragraph.AddText("" + shift);
paragraph.AddLineBreak();
}
doc.Push(paragraph);