DocumentBuilder version: 8.0.0 (according to the website I downloaded it from)
Installation method: download arm.64deb
package from Download ONLYOFFICE Document Builder | ONLYOFFICE
OS: Ubuntu (running in docker on mac)
Not sure what I’m missing, I’ve downloaded an installed the prebuilt package from the above link, but trying to run some sample code (below) is giving me the ReferenceError: Api is not defined
, not sure if i’ve missed some setup/installation procedure?
script.docbuilder
builder.CreateFile('docx');
let oDoc = Api.GetDocument(0);
let oPar = oDoc.GetElement(0);
oPar.AddText(Argument['key']);
oPar.AddLineBreak();
oPar.AddText(Argument['key2']);
builder.SaveFile('docx', 'simple.docx');
builder.CloseFile();
Running:
/opt/onlyoffice/documentbuilder/docbuilder '/project/script.docbuilder'
ReferenceError: Api is not defined
at <anonymous>:1:12
UPDATE
Ended up modifying a different sample script and had It run without failure:
builderJS.OpenFile('path_or_url', '/project/sample.docx');
builderJS.CreateFile('docx');
builderJS.SetTmpFolder('/project/tmp');
builderJS.SaveFile('docx', '/project/sample_update');
builderJS.CloseFile();
where /project/
is a volume mount to my current working dir where i’m running the docker container from.
So I suppose the Api
object is not available, still struggling to comprehend the docs on this one…
UPDATE 2
So looks like I may have missed the difference between builder
and builderJS
, it also seems like the Api
is available after I’ve opened/created a file. Seems simple now, but this was a struggle to comprehend