Meet ONLYOFFICE Docs Cloud, complete office software as a service
Meet ONLYOFFICE Docs Cloud

Send array to docbuider script

Good day!
How I can send array to docbuider script (not variables)?
And can I use for-each to create paragraphs for example (use array)?
I don’t find any examples…

DocumentBuilder version: 7.2.0
Installation method: deb
OS: mint

Hello @DmitryPozdeyev
Please clarify your request. As far as I see some docbuilder methods contain array as data type.

And can I use for-each to create paragraphs for example (use array)?

Do you mean AddText, but via array?

I use java and send parameters using bash:
/opt/onlyoffice/documentbuilder/docbuilder “–argument={“fz”:“example1”,“number”:“3474-5-1-3-021122”,“object”:“example 3”}” test.docbuilder
This work properly.
But I want to send into script, not only something like key-value… I want to send array

We are checking the situation. I’ll update this thread when we have something to share.

Probably, it will be useful. You can send array to a script this way:
docbuilder '--argument={"array":["Paragraph1","Paragraph2","Paragraph3"]}' ./test.docbuilder

As for paragraphs:

var oDocument = Api.GetDocument();
var Array   = Argument["array"];

Array.forEach(function(item, i, Array) {
    var oParagraph = Api.CreateParagraph();

builder.SaveFile("docx", "ArgumentUse.docx");

Thanks! It is usefull!
Now I create dobuilder script in Java program and execute pre generate script.

We are glad that the issue is solved. Please feel free to contact us if you face any issues.