zephan
19 February 2024 08:08
1
Hi! I’m trying to write a plugin that can create the slide content base on the data of the user input, but I can’t find a way to set the position for a table or an image.
The image is always inserted in the top left.
Example:
var oImage = Api.CreateImage(“image url“, 100 * 36000, 50 * 36000);
oSlide.AddObject(oImage);
The API Link:
Similar Topic: How to modify tables/create tables of a custom size in Presentation - Document Builder - ONLYOFFICE
Is there any relevant method can do this?
DocumentBuilder version: last version (8.0)
Installation method:
OS:
Hello @zephan
We are checking the described scenario. I will update this thread when we have something to share.
Hello @zephan
Sorry for the late reply.
It seems that it should work this way:
var oPresentation = Api.GetPresentation();
var oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
var oImage = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/step2_1.png", 360 * (10 ** 4), 180 * (10 ** 4));
oImage.SetPosition(360 * (10 ** 4), 180 * (10 ** 4))
oSlide.AddObject(oImage);
Get the information about image position:
var oPresentation = Api.GetPresentation()
var json = oPresentation.GetSlideByIndex(0)
.GetAllDrawings()[0]
.ToJSON()
console.log(JSON.parse(json)['extX'])
console.log(JSON.parse(json)['extY'])
Please clarify if this solution matches your needs.