ashar_oz contact
Chief author, Open Source enthusiast, Web Programmer, and UI/UX Designer.
Wednesday, July 11, 2012 at 11:09

Hii guys, today we will share some tips for you, i'm sure that some day you would need it . This tips is about how to convert document format (that supported by LibreOffice) to pdf, doc. docx, xls, xlsx, odt, ods collectively.

There are many ways to convert a document, one that is commonly use is an online converter, through this tips not only resolve your problem but also you can helping others people to convert their documents via your server (you can build such us web converter portal).

Prepare the Application
To do this job some aplication that need to install are unoconv, LibreOffice, and Ubuntu 11.04 or more, why you need an Ubuntu 11.04 or more because the previous version (of Libreoffice/OpenOffice) is not support for docx and xlsx document.

Install the latest LibreOffice and it's library
On most Ubuntu version LibreOffice is defaulty installed, just upgrade it to the latest version.

  • apt-get install libreoffice
Install unoconv
unoconv is a command line utility that can convert any document format (doc, docx. odt, ods, xls, xlsx) that LibreOffice can import, to any file format (xml, pdf, doc, docx. odt, ods, xls, xlsx) that LibreOffice is capable of exporting.
  • apt-get install unoconv
Installing LibreOffice is more than enough to answer your needs in converting document, but for some reason unoconv do better (despite using the same library) when the output is use by other application, we can say it more acceptable.

Batch Convert Document to csv, pdf, jpg, docx, xlsx, odt, or ods
To batch convert document you have to work under terminal, prepare a document that will be converted in a folder (can be consist of several sub-folders),  then do following :

Synopsis :
  • unoconv [options] to-file from-file
Convert single xls format to pdf
  • unoconv -f pdf some-document.xls
Convert single png format to jpg
  • unoconv -f jpg some-document.png
Batch Convert docx format to pdf
  • unoconv -f pdf *.docx
Batch Convert xlsx format to ods
  • unoconv -f ods *.xlsx
Batch Convert csv format to xlsx
  • unoconv -f xlsx *.csv
Batch Convert csv format to ods
  • unoconv -f ods *.csv

You can change the option, source, and destination format according to your needs. Some document format  which supported by the this application are pdf, odf, odt, ods, xls, xlsx, doc, docx, rtf, ppt, pptx, csv, png, jpg, bmp and svg.

yes, that is. I hope this would help your work :)