How to pass variable user fields to headless writer

I’m really hoping to find a solution to a problem which has been presented to me. I need to populate, what I think would be either a series of user fields or Showvariable fields via the command line in a writer doc on my Ubuntu machine. Then save the file to a print dump, to ultimately be converted to a tiff (their format, not mine) via ImageMagick. The problem lies in I can’t seem to find any info on passing anything into a file.

The simple option I imagine would be something like this:

soffice --headless --print-to-file -field1=data1 --field2=data2… template.odt

I also have the ability to pull the fields from a MySQL db, if there was a way to pass an id or something into the file as a reference.

Is there anyway to accomplish this? Thanks for any help you can offer. I’m still looking for a solution, in case anyone is wondering.

I’ve been wondering the same thing. I’ve only been able to accomplish it outside of LibreOffice. The ODT format is actually a zip file. Open one with zip software and you can see the contents. All of the text in the document is kept in the content.xml file. I’ve been able to unzip the document, make modifications to the content.xml file with sed in bash and then zip it back up. The only catch is you have to rebuild the archive in a particular way explained here. Once it is modified and re-archived then you could pass the ODT back to LibreOffice for printing. I wish I could find the shell work I did but it has been months. I ended up moving my project to Python for portability.

There’s also FODT format that is a single XML file, so no unzipping/zipping, just sed’ing your document.