Convert text files to PDF

Hi, I’m looking for an app, Automator action, AppleScript, Keyboard Maestro macro, etc. that will let me batch convert .txt files to PDFs without having to open them individually in TextEdit and manually print to PDF. Any suggestions would be appreciated. Thanks.

If you search the Mac App Store you’ll find lots of free-to-cheap drag-and-drop apps if you search text to pdf

If you have brew Installed, you can install enscript and create a little batch file to do the conversion for you. From Terminal:

brew install enscript

After the magic, create a batch file

enscript - -word-wrap -p  - "$1" | pstopdf  -i -o "$2"

Oh, meant to mention, those two dashes before word-wrap should be together, Discourse makes two dashes into an em dash —, so I added a space.

And save it to /usr/local/bin/txt2pdf

Then chmod +x /usr/local/bin/txt2pdf

Now you can just:

txt2pdf myfile.txt myfile.pdf

The idea is then to put this bash script within an automator with a for-each front end to do batch conversions.



This is the sort of thing Automator is great at.

Here is one example:

I would convert this to a folder action and have the PDFs saved to a second folder.

1 Like

These are all very helpful, thanks! I had searched the Mac App Store, but the search function is terrible, and everything I saw was a PDF to Text converter, rather than the other way around - I must have given up too early. I’ll give the bash script/Automator set up a try first, just to see if I can make it work.