Converting ODF documents to PDF with WebODF

2011-02-23

It is quite common that one wants to send ODF files to people that lack the software to display ODF. One workaround is to convert the ODF to PDF. Most office suites that support ODF can export to PDF. To compare how different office suites do this conversion one can use the website OfficeShots. This website offers the ability to perform this conversion in many office suites at once and to compare the results.

WebODF wants to play with the grown-ups. So I have extended WebODF with the ability to convert from ODF to PDF. Here is a small script that shows how to do this conversion for a file /home/user/file.odt:


# compile WebODF
git clone http://git.gitorious.org/odfkit/webodf.git
mkdir build
cd build
cmake ../webodf
make
cd ../webodf/webodf
# perform a conversion
FILE=/home/user/file.odt
cp "$FILE" .
FILE=`basename "$FILE"`
../../build/programs/qtjsruntime/qtjsruntime --export-pdf render.pdf "odf.html#$FILE"
ls render.pdf

Comments

Nice. I'm currently using a

Nice. I'm currently using a headless openoffice instance to convert office documents to PDFs on a site that includes some simple document management. Perhaps WebODF will be an alternative in the future. Or I'll use them together, using the openoffice instance to convert the uploaded documents to ODF and WebODF to display them in the browser. :)

Impressing work! The

Impressing work! The Android-app and the nativeQtClient do work too? They are sharing the js-code? Wow.

Re: Impressing work!

Yes, 90% of the code is the same. Access to the filesystem is different in the android app and the nativeQtClient. All these applications need some 'native' code to set up a web widget in which WebODF can be loaded and some code to read files from the local disk. The rest of the code is shared.