Creating document by passing builder script as string to builder api

I want to create a document using docbuilder api by passing the docbuilder script as string instead of the url location of the file. Is this doable?

Hello @anup

Unfortunately, Document Builder cannot operate without .docbuilder script.

I have the following builder script in a file:

builder.OpenFile(Argument["inputfile"])
var oDocument = Api.GetDocument();
oDocument.SetFormsData(Argument["data"]);
builder.SaveFile("docx", Argument["outputfile"]);
builder.CloseFile();

Can OpenFile and SaveFile receive arguments ? It does not seem to work for me. Is there any other way to pass arguments to OpenFile and CloseFile ?

You should use jsValue instead for arguments that are passed to the builder methods as per 3 item of this article, for instance, like that:

var sDocURL = Argument["DocURL"];
builder.OpenFile("jsValue(sDocURL)");
...
var sDocName = Argument["DocName"];
builder.SaveFile("docx", "jsValue(sDocName)";
builder.CloseFile();

Thanks. It worked. I am actually trying to use this script to dynamically fill templates and generate a document from a python backend. Can I do something like this using automation api ? I can not find any documentation about the API endpoints for automation API but only its methods.

Automation API allows interacting with the editor from outside. Please see an example here:

It generally has the same interface as plugins, so you are generally connecting to the editor:

Please note that Automation API is available in Developer Edition of ONLYOFFICE Docs only.