How to generate automatically ODT documents from libreoffice using variables

3

I have an ODT certificate template which I need to customize with a few elements (name, surname, date, etc.) before printing it.

So I would be able to fill it with the data provided in an external document (which could be a .txt file containing for example name, surname, etc.). Say I have to print 100 or so of such certificates, and I have already the parameters data in the external file, I would be able to pass the parameters to an headless libreoffice instance and print a customized version for each entry, all this done through a script. The alternative is to fill the data manually in the template for each certificate, which is dumb, boring and error-prone.

I could use LaTeX but I already prepared the certificate in ODT format and I don't know LaTeX/TeX enough to customize it with the same level of control I already got with libreoffice (for example: font family and size of the various paragraphs, exact location of text, etc. etc.).

Do you know some way to achieve this with libreoffice?

Related question: How can I write an .odt programmatically?

Difference in my case is that I only need to fill a few text values.

NoUserFound

Posted 2014-05-18T21:35:20.577

Reputation: 153

Answers

2

LibreOffice Writer has a mail merge feature to do what you're asking.

Don't be fooled by the name, which is now standard in office application suites. The general task of producing a batch of documents with fields filled in from a data set is still called mail merge, for hysterical raisins (merging one's contact database with a form letter was the first widespread task where this feature was required).

bignose

Posted 2014-05-18T21:35:20.577

Reputation: 1 981

The mail merge feature seems indeed very specific for sending mails or e-mails, can't be easily adapted to print generic documents with auto-filled fields. – NoUserFound – 2014-05-19T08:27:30.477

2

I figured out how to use the feature, and looks like what I need. This youtube video: https://www.youtube.com/watch?v=prZJ4w-q9AA was also useful to see how to use the feature in combination with a datasource.

– NoUserFound – 2014-05-20T08:49:03.470