Printing python code to PDF
pdf, printing, python
Solution
For the anti-plagiarism part, I can't help you. For printing a py script with syntax highlighting, a traditional tool is `enscript`:
enscript -E -q -Z -p - -f Courier10 readmaya.py | ps2pdf - out.pdf
Here, `enscript` does the syntax highlighting and produces postscript. You could use any of several possible tools for the second step of converting postscript to pdf. I have shown here `ps2pdf` which is from the ghostscript package.
Installation
On a Debian- or Unbuntu-like system, `enscript` can be installed with:
apt-get install enscript
On a Debian- or Unbuntu-like system, `ps2pdf` is part of the `ghostscript` package which is likely already installed. If it isn't. run:
apt-get install ghostscript
Problem
I have to print to PDF a discrete amount of python script. The code should be included as text, rather than image, as it must be checked by an anti-plagiarism mechanism (I do not have to take care of this, it is just requested that the pdf is not made from an image, that's all). It is also necessary to have syntax highlighting. Do you have any suggestion regarding a specific tool for this?