Get Started
Documentation
Macros
More information
|
window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [args], callback)Description
Defines the method that inserts a content control containing data. The data is specified by the js code for Document Builder, or by a link to the shared document. Usage
This method should be used in the following way: window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [obj]); Where obj is a JSON array: [ { "Props": { "Id": Number, "Tag": "{String}", "Lock": Number }, "Script": "var oDocument = Api.GetDocument();var oParagraph = Api.CreateParagraph();oParagraph.AddText('Hello world!');oDocument.InsertContent([oParagraph]);" } ] Each new element in the array will create a new content control. [ {"Props": {...}, "Url": "http://"}, {"Props": {...}, "Url": "http://."}, {...}, {...}] The Props key can have the following values:
Besides the Props key, there must be a Key/Value pair containing the Url or Script key that defines the data that that the content control will contain. If the Url key is used, its value must be a link to the shared file. If the Script key is used, its value must be a script that will be executed to generate data within the content control. Example 1
{ "Url": "https://example.com/script.docbuilder" } Example 2
"Script": "var oDocument = Api.GetDocument(); var oParagraph=Api.CreateParagraph(); oParagraph.AddText('Helloworld!'); oDocument.InsertContent([oParagraph]);" Returns
The method returns the data which the created content control contains (in JSON format) [ { "Tag": "Document", "Id": 0, "Lock": 0, "InternalId": "1_713" } ] |
|||||||||||||||
© Ascensio System SIA 2021. All rights reserved
|