Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have students who, when asked for PDF, sometimes hand me an OpenOffice document or spreadsheet. file(1) can identify these documents, but I've been unable to discover how to convert them to PDF using the command line. (The man page for ooffice(1) lists an option to print a document but not to convert to PDF.) Google is unhelpful, except for giving me the uneasy feeling that this can't be done without a nifty script in a language I don't know against an API whose documentation I can't find.

Can anyone help me solve the problem of converting an OpenDocument to PDF using only the Unix command line?

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

I think the most straightforward way would be to setup a pdf printer on your box and then just:

ooffice -pt pdfprinter studentwhodoesntfollowdirectionswell.odt

Edit: Just found a post on the Ubuntu forums with someone who arrived at the same solution I suggested (with handy dandy instructions). printing to pdf from command line [SOLVED]

Edit 2: I just came across unoconv which is a python script that uses OOo's UNO bindings. So I just wanted to update this answer

share|improve this answer
    
Gross, but it should work, thanks. Link to Ubuntu thread with details of the filename gets the check mark. –  Norman Ramsey Jan 5 '10 at 20:29
2  
unoconf file.odt file.pdf is the better way. You'll get the yummy metadata that a pdf printer doesn't include. –  Tobu Jun 11 '10 at 14:37
add comment

$oowriter --convert-to pdf --invisible name.odt

That's all. If your CLI is graphic, you can ommit the "--invisible" option.Tested on opensuse 12.3.

share|improve this answer
1  
Can you expand on your answer with more detail? –  Sickest Feb 26 at 19:12
add comment

I do this using cups-pdf. You'll need to have OpenOffice installed, and you have to run ooffice in headless mode so the application doesn't launch a GUI.

the PDF printer is usually in the repositories, so simply sudo apt-get install cups-pdf or yum install cups-pdf.

Next you'll need to install the printer. If you wish, you can install a printer via the command line.

If you install a printer via the GUI, (on Ubuntu) it's as easy as System -> Administration -> Printing. Click the arrow and select New Printer:

alt text

Go through the wizard and make note of what you name your printer, you'll need it from the command line. As you can see, I've used cups-pdf:

alt text

Finish the wizard and you're ready to convert. Open up a terminal and run:

ooffice -headless -nologo -pt cups-pdf doc.odt

Under your home directory you'll have a PDF folder. Inside will be your converted document.

share|improve this answer
    
+1 thanks. Your last name isn't "Skeet"? –  Norman Ramsey Jan 5 '10 at 20:30
    
Nope, different people :) –  John T Jan 5 '10 at 20:40
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.