What is a simple way to convert a Unicode text file to PDF on the command line on macOS?
One can open a text file in e.g. TextEdit and print it as a PDF. Is there a command line equivalent?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityThe following has been tested on Mac OS 10.12.1.
To convert a Unicode text file text.txt to a pdf file text.pdf:
textutil -convert html test.txt
cupsfilter test.html > test.pdf
To specify font:
textutil -font 'Menlo Regular' -fontsize 11 -convert html test.txt
cupsfilter test.html > test.pdf
> cupsfilter release-notes.html
> cupsfilter: No filter to convert from text/html to application/pdf.
I've tried you method but got this error, maybe do you know what's wrong ?
https://pandoc.org/ can convert from text to PDF (and much more). Basic invocation:
pandoc input.txt -o output.pdf