views:

203

answers:

3

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?

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.

+1  A: 

If you use vim, check this link

Yassin
Didn't work using the Win32 version. The :hardcopy command popped up a dialog box to print it. It's just pushing the syntax highlighting thru a PS converter. Pretty nifty, but *nix specific.
NoMoreZealots
+2  A: 

Two syntax highlighters I've used a lot are enscript and source-highlight.

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

Both should be available via Cygwin

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

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

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: 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
baol
+1  A: 

I use this. It generates .ps. Then you can run ps2pdf.

# Copyright 2004 Rutger E.W. van Beusekom.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

outfile=$1
shift

a2ps -1 --highlight=normal --pretty-print=cxx --line-numbers=1 -M a4 -L80 -g \
-o $outfile $* --prologue=color --right-title=%p. --left-title \
--left-footer --right-footer --header --medium=a4

You could also use Doxygen with source browsing enabled. There is also htmlize.el by Hrvoje Niksic for emacs.

Eddy Pronk