Hacker News new | ask | show | jobs
by minighost 3206 days ago
Vim can do this

1. Open your script/code in vim editor

2. Enable syntax & set the required color scheme

:syntax on :colorscheme darkblue

3. Print the file in PS file format

:hardcopy >/tmp/filename.ps

4. Convert the PS file to PDF format

$ ps2pdf /tmp/filename.ps

5. Now you can open filename.pdf

3 comments

You can also do :TOhtml, then open the html file with your browser and print to pdf. A bit simpler imo.
Or convert the ".ps" file into ".jpeg" instead ?

4. Using ghostscript: gs -sDEVICE=jpeg -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r300 -sOutputFile=filename.jpg filename.ps

On a Mac you can use pstopdf (or just open the PS file in Preview).