Forum OpenACS Development: Re: JODconverter vs. OpenOffice/LibreOffice Command Line

Posted by Antonio Pisano on
I second your choice. Running OpenOffice/LibreOffice from the command line is a very powerful way to convert from one format to another.

One thing I do, for example, is to create a print template as a flat odt (.fodt), then use it as a lean and mean adp template in my page, to be filled with data. Once I have produced the fodt, I can convert it to whathever formats OpenOffice/LibreOffice supports. I have struggled a lot with prints in the past, and I find this just wonderful, as most of the stupid formatting is handled by the office suite itself!

I don't know JODconverter, but back in the days when direct calls were not possible I remember using unoconv in a somewhat similar way. No need to say that requiring one software is easier than requiring two.


Posted by Malte Sussdorff on
Hi Antonio,

How do you call libreoffice? If I try to call libreoffice directly using exec, I have a problem with the PATH missing.

[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!
Warning: failed to read path from javaldx
while executing
"exec /usr/bin/libreoffice --headless --convert-to pdf --outdir /var/lib/aolserver/ ..."
invoked from within
"ns_proxy eval $handle "exec $call""

Curious how you call it and if you might have a wrapper function for it. I tried:

exec /usr/bin/libreoffice --headless --convert-to $convert_to --outdir $outdir $oo_file

Posted by Malte Sussdorff on
Solved my own problem using google and looking for a PHP solution instead of TCL, which taught me that the HOME env was missing....

exec -- /usr/bin/env HOME=[acs_root_dir] /usr/bin/libreoffice --headless --convert-to $convert_to --outdir $outdir $oo_file

Posted by Antonio Pisano on
Yep, more or less the same thing I came up with. The problem is Libreoffice needs to write stuff in its home directory, therefore this must be set to something you have write permissions into.

Kudos for solving! :-)

Posted by Frank Bergmann on
We've got the oofice call in /packages/intranet-invoices/www/view.tcl, for example. That looks like this:

set result [im_exec bash -l -c "export HOME=~\$\{whoami\}; ooffice --headless --convert-to pdf --outdir /tmp/ $odt_zip"]