是否有一个命令行C ++到PDF转换器语法高亮? [英] Is there a command line C++ to PDF converter with syntax highlighting?

查看:279
本文介绍了是否有一个命令行C ++到PDF转换器语法高亮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要提供源代码文档w /行号,这本质上只是一个PDF的源代码与语法高亮和行号。有没有任何现有的命令行工具的窗口,我可以从一个脚本调用作为构建版本脚本?

I need to supply "Source code documents w/ Line numbers" which is essentially just a PDF of the source code with syntax highlighting and Line numbers. Is there any existing command line tools for windows that I could call from a script as a "build release version" script?

现在我使用VC ++手动,它甚至不是开发环境的代码是一个TI处理器,和一个PDF打印机驱动程序,它为每个打印的文件弹出。

Right now I'm doing it manually using VC++, which isn't even the dev enviroment the code is for a TI processor, and a PDF printer driver, which has a pop up for each file I print.

推荐答案

我使用的两个语法高亮指令是 enscript source-highlight

Two syntax highlighters I use are enscript and source-highlight.

第一个可以输出到PostScript(可以使用ps2pdf转换为PDF),第二个以HTML,LaTeX和其他格式生成输出。

The first can output to PostScript (that you can convert to PDF using ps2pdf), the second produces output in HTML, LaTeX and other formats.

两者都应通过 Cygwin 提供

编辑:在我的系统上,以下命令将打印当前子树中的所有cpp文件。

On my system the following command will print all the cpp files in the current subtree.

find . -name "*.cpp" | xargs enscript -Ecpp -fCourier8 

虽然下面会产生一个 code.pdf 具有相同内容的文件

While the following will produce a code.pdf file with the same content

find . -name "*.cpp" | xargs enscript -Ecpp -fCourier8 -o - | ps2pdf - code.pdf

PS:并给予 - color = 1 表示颜色输出, -C 表示行号。

PS: and give the --color=1 for color output and -C for line numbers.

find . -name "*.cpp" | xargs enscript --color=1 -C -Ecpp -fCourier8 -o - | ps2pdf - code.pdf

这篇关于是否有一个命令行C ++到PDF转换器语法高亮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆