简体   繁体   English

如何在Linux命令行中将文本文件打印为PDF文件

[英]How to print text file to PDF file in Linux command line

I have some Python source file that I would like to print to PDF for later reading I used to do this with gedit, file by file but there are a large number of .py file I would like to automate this process 我有一些Python源文件,我希望将其打印为PDF,以供日后阅读。我曾经使用gedit逐个文件地执行此操作,但是有大量的.py文件可以实现此过程的自动化

How can I do this ? 我怎样才能做到这一点 ? Better with Syntax highlighting too, such as with gedit 语法高亮也更好,例如gedit

Thanks in advance 提前致谢

我将使用a2ps很好地将其格式设置为Postscript,然后使用ps2pdf(来自Ghostscript)将Postscript转换为PDF。

使用此单个命令

$pandoc -o output.pdf input.py

you might encounter Problems with eg Umlaute (ÄÖÜ) or ß. 您可能会遇到Umlaute(ÄÖÜ)或ß等问题。 If so, I suggest wkhtmltopdf as described here . 如果是这样,我建议按此处所述进行wkhtmltopdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM