sdkjs-plugins icon indicating copy to clipboard operation
sdkjs-plugins copied to clipboard

InsertAndReplaceContentControls don't load images with CreateImage

Open lorenzoale opened this issue 2 years ago • 3 comments

Do you want to request a feature or report a bug?

What is the current behavior? When I use createimage with CallCommand, the image is created (either with url as the example: Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000); or with base64) However when I add the same line of code inside InsertAndReplaceContentcontrols script, it creates the control, but doesn't load the image, even if it allows me to load it afterwards. I may be doing something wrong? The idea is to replace several content controls dinamycally by texts or images. I could do it one by one going through the content controls in this case I would need to deal with the callbacks after each replacement. The insertAndReplace seems to be perfect for this task. I tried:

  • creating a picture control: window.Asc.plugin.executeMethod("AddContentControlPicture", [{"Lock" : 3}]);
  • creating a normal one: window.Asc.plugin.executeMethod("AddContentControl", [2, {"Lock" : 3}]); And then
  • the script : _script = "var oDocument = Api.GetDocument(); var oParagraph =Api.CreateParagraph();var oDrawing = Api.CreateImage('https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png', 60 * 36000, 35 * 36000); oParagraph.AddDrawing(oDrawing); oDocument.InsertContent([oParagraph]);";
  • or the script inserts the image inside the control: _script = "var oDocument = Api.GetDocument(); var oDrawing = Api.CreateImage('https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png', 60 * 36000, 35 * 36000); oDrawing.InsertInContentControl(1);";
  • or even others combinations.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

What is the expected behavior?

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins? As recomended I installed 7.1.1 Many thanks in advance

lorenzoale avatar Aug 12 '22 15:08 lorenzoale

@lorenzoale Hi! At the moment there is no way to install an image using the InsertAndReplaceContentControls method. Created a bug #58521 in our private repository.

askonev avatar Aug 15 '22 11:08 askonev

Any updates on this?

fr3fou avatar Apr 12 '23 15:04 fr3fou

Any updates?

zahari00 avatar Aug 31 '23 10:08 zahari00