Create a libreoffice text document programmatically from a template

I am trying to find a way to create a .odt document from a .ott template programmatically. This should be done programmatically. Any ideas on how to achieve this?

I found several ways to generate .odt files in Java ( http://incubator.apache.org/odftoolkit/odfdom/index.html ), but there seems to be no way to generate a document from. ott.

The implementation language is more or less irrelevant, but JavaScript on Node.js may be the best.

Thanks for your help in advance.

+7
libreoffice
source share
2 answers

Have you checked node -odt ? It seems to me that he supports what you need.

In accordance with its documentation:

A node js tool for working with OpenDocument text files.

and one of his examples:

var fs = require('fs') , odt = require('odt') , template = odt.template , createWriteStream = fs.createWriteStream var doc = 'mytemplate.ott'; var values = { 'subject': 'My subject value' }; // apply values template(doc) .apply(values) .on('error', function(err){ throw err; }) .finalize(function(bytes){ console.log('The document is ' + bytes + ' bytes large.'); }) .pipe(createWriteStream('mydocument.odt')) .on('close', function(){ console.log('document written'); }); 
+2
source share

I wrote a utility in python called Secretary to create ODT documents from ODT templates. You can check it out at https://github.com/christopher-ramirez/secretary , maybe this can help you. The next version will support the addition of images to visualized documents.

+2
source share

All Articles