Possible to print to PDF from Mac terminal?

lpr is indeed the correct command. There's not much to it, just

lpr filename.pdf

should simply work, presuming that the default printer is set correctly. If not, you might have to do

lpr -P printername filename.pdf

Note that there's a man page -- "man lpr" if you need to see the content. Yes, the CUPS print daemon that OS X uses is already PDF aware.


I know that I have seen something in a merely hidden system folder:

/Library/Scripts/Printing Scripts/Convert To PDF.scpt

I have created a new application from AppleScript but calling the script directly should work also.

EDIT: actually you simply can call

/System/Library/Printers/Libraries/convert -f file.rtf -o file.pdf -j "application/pdf"

1) The Open Source Word processor, AbiWord, includes an option of converting between any formats it knows on the commandline, including PDF e.g.,

abiword --to=pdf filename.html

(It'll also handle, e.g., MS Word .doc files, .docx, .odt, .rtf, etc., both input and output.)

I know it's available for Mac, though I've never used it on a mac.

2) The ebook-convert command line program from calibre (on mac you need to follow the instructions here to get the commandline tools) is useful for many formats, too.

ebook-convert filename.html filename.pdf

It can handle .rtf and .odt input, and lots of ebook formats like .epub and .mobi.

3) PrinceXML can be used on the commandline, and will convert HTML to PDF very beautifully.

4) There's wkhtmltopdf, which uses the webkit engine to convert HTML to PDF from the commandline. I've never tried it.

5) I can think of other methods using, e.g., ConTeXt or pdflatex, but they get more and more involved.