Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Does anyone know how to convert an ODT file (LibreOffice) to PDF?

share|improve this question
1  
Related (but not a duplicate!): How to convert pdf file to an odt file? –  Eliah Kagan Jan 11 '13 at 19:15
add comment

6 Answers

up vote 29 down vote accepted

Just open the document with libre office and choose Export as PDF...:

enter image description here

For a command line solution there is unoconv Install NAME that converts files from the command line:

unoconv -f pdf mydocument.odt

Note: Only starting from Ubuntu 11.10 unoconv depends on Libre Office. Previous unoconv versions (from Ubuntu <= 11.04) depend on Open Office (but it will also run with Libre Office).

share|improve this answer
add comment

You can also use the command-line of libreoffice for your purpose. That gives you the advantage of batch conversion. But single files are also possible. This example converts all ODT files in the current directory to PDF:

libreoffice --headless --convert-to pdf *.odt

Get more information on command-line options with:

man libreoffice

(Note: Due to bug 37531, you have to close all running instances of LibreOffice before this command will work.)

share|improve this answer
    
Another argument for command line usage is that for instance in my case the gui has all of a sudden started producing flawed pdf's, but the command line still works like a charm. –  Hermann Ingjaldsson Feb 27 '13 at 14:16
1  
Thi9s works, but it has a problem: if the GUI is open the command will do nothing (not even show an error). Ugly, but with this workaround you can open a new instance: --env:UserInstallation=file:///path/to/some/directory. –  tokland Sep 16 '13 at 13:14
1  
@tokland: There's a bug report for that: bugs.freedesktop.org/show_bug.cgi?id=37531 –  Mechanical snail Dec 2 '13 at 2:02
add comment

Nautilus Script

This script utilizes libreoffice to convert files compatible with LibreOffice to PDF.

#!/bin/bash
## PDFconvert 0.1
## by MHC (http://askubuntu.com/users/81372/mhc)
## License: GPL 3.0
## depends on python, libreoffice
## Note: if you are using a non-default LO version (e.g. because you installed it 
## from a precompiled package instead of the official repos) you might have to change
## 'libreoffice' according to the version you're using, e.g. 'libreoffice3.6'

# Get work directory
base="`python -c 'import gio,sys; print(gio.File(sys.argv[1]).get_path())' $NAUTILUS_SCRIPT_CURRENT_URI`"

#Convert documents
while [ $# -gt 0 ]; do
    document=$1
    libreoffice --headless --invisible --convert-to pdf --outdir "$base" "$document" 
    shift

done

For installation instructions see here: How do I install a nautilus script?

share|improve this answer
2  
I just hope that such function as "lipreoffice" would be in OSX too. Sometimes, I feel my hands so short when I have to use Mac. –  Masi Mar 6 '13 at 18:31
add comment

Note: I decided to delete my answer from this question and to post a modified version of it here when I realised that unoconv doesn't deal with psw files at all well, and doesn't convert them successfully to other formats. There may also be problems with docx and xlsx formats.


However, Libreoffice fully supports many file types; full documentation is available at the official site, which details the valid input and output formats.

You could use the command-line libreoffice convert utility or unoconv, which is available in the repositories. I find unoconv to be very useful, and it is probably what you want. Even though Takkat has briefly mentioned unoconv, I thought it would be useful to give some more details and a batch conversion one-liner.

Using the terminal you could cd to the directory containing your files and then batch convert all of them by running a one-liner like this:

for f in *.odt; do unoconv -f pdf "${f/%pdf/odt}"; done

(This one-liner is a modification of my translate script featured in this answer.)

If you later want to use any other file formats, just substitute the odt and pdf for any other supported input and output formats. You can find the supported formats for a file type by entering unoconv -f odt --show. To convert a single file use, for example, unoconv -f pdf myfile.odt.

Further information on and options for the program can be found by entering in terminal man unoconv or by going to the Ubuntu manpages online.

share|improve this answer
add comment

Consider using the docspal service (http://www.docspal.com). It is free, fast and supports lots of formats. Hope, it will be useful for you.

share|improve this answer
add comment

Another Nautilus Script

This very simple and lightweight Nautilus Script uses unoconv to convert selected file(s) compatible with LibreOffice to PDF format:

#!/bin/sh
#Nautilus Script to convert selected LibreOffice-compatible file(s) to PDF
#
OLDIFS=$IFS
IFS="
"
for filename in $@; do
unoconv --doctype=document --format=pdf "$filename"
done
IFS=$OLDIFS
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.