C-Command Software Forum

Slightly Off topic - commandline eml to pdf

Michael, this isn’t really an EF question unless EF has a way to do it - I would understand why if you removed it from the forum.

Many receipts I get by email and they aren’t pdf, they are email text (or sometimes html). I plan to store them in EF as eml and at the end of each tax year to export receipts files into a tree structure month by month. Now pdf may be an accepted format that everyone who needs to can read but eml isn’t - how it behaves on different platforms with different email clients is not too consistent - I can’t expect my accountant to be able to read it.

Now I could print the email to pdf on its way in to EF but that’s a miserable way to do it - it wastes storage and I can store the eml faster than I can pdf. So I’d prefer to store as eml, then do the export at the end of the year and then traverse the exported tree converting the eml to pdf. So I’m wanting a commandline way to convert eml to pdf. I have no problems with tree traversal (hey I’m a unix person, its easy), only with the conversion. There are millions of fancy gui-based tools out there (most of which not free) but its hard to buid them into a traversal which puts the results in the same folders. There must be a way to do this with applescript since most stuff can print to pdf on here - the catch is whatever does it has to understand the header structure of eml content so as to chop out the delivery stuff (otherwise just text would do). I used to use pdftk to do nifty stuff like this but I didn’t (and probably won’t) build macports for lion (not even sure it still will work).

Suggestions please - it there an easy way to do it ?

andy

I don’t know of a command-line tool that will do this. Maybe try using Automator to print the files to PDF? There’s the CUPS-PDF printer driver. I think there used to be a way to select this in Automator when printing Finder items, but now (on 10.7) that action has no options for me. The print action for Outlook will let me select a printer, though.

There is a option to select a printer in Automator under 10.6. I just tried it, but neither Mail nor Outlook responds to the print request for an email message (.eml). The same problem occurs with the Print item in the Finder’s File menu. (And Michael is right, the option is gone under 10.7. So much for progress. Another option may be to change your default printer, “print” the message, then change it back.)

I tried the print Automator action with documents from a few other apps and it worked quite well.

So if you can find an email client that actually likes to print a message, you should be all set…