Convert documents (ODT, DOC) to PDF from the command-line
Let’s say, for instance, that you want to convert several OpenOffice (or Microsoft Office) documents to PDF. Instead of opening each document at a time and exporting it to PDF, you could automate the process this way:
What tools do you need?
- OpenOffice.org (I’m using verson 3.2.1, downloaded directly from OOo)
- CUPS (most probably you already have it)
- CUPS-PDF (search repositories)
Once you have CUPS-PDF installed, you still may need to add the printer to CUPS. To do that, open a web browser and go to:
If CUPS-PDF is not there, go the the “Administration” tab and click on “Add Printer”. Follow the steps to add CUPS-PDF, and when asked for a PPD file, look at (for Linux distributions other than Debian Lenny, the path may differ):
/usr/share/ppd/cups-pdf/CUPS-PDF.ppd
Once CUPS-PDF is configured you can start converting documents to PDF from the command-line.
To convert a single file type:
$ soffice -invisible -norestore -pt CUPS-PDF filename.odt
To convert all ODT files in the current directory:
$ for i in *.odt; do soffice -invisible -norestore -pt CUPS-PDF "$i"; done
And another way, with find:
$ find . -name '*.odt' -exec soffice -invisible -norestore -pt CUPS-PDF '{}' \;
You’ll find PDF files in a folder called “PDF”, in your home directory.
Further reading: http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html
FANTÁSTICO ESE CONVERTIDOR AYUDA A LA POBLACIÓN ESTUDIANTIL, BRAVO CON ESO……………