Ask Your Question

How to pass variable user fields to headless writer [closed]

asked 2012-11-27 22:28:41 +0200

modF gravatar image

updated 2012-12-03 17:49:35 +0200

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.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-19 14:01:42.366132

1 Answer

Sort by » oldest newest most voted

answered 2012-12-20 03:40:12 +0200

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.

edit flag offensive delete link more


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

Alexander Koptelov gravatar imageAlexander Koptelov ( 2019-03-18 16:01:57 +0200 )edit

Question Tools


Asked: 2012-11-27 22:28:41 +0200

Seen: 822 times

Last updated: Dec 20 '12