ANN: py2pdf 0.2 -- Python syntax coloring in PDF

Dinu C. Gherman gherman at
Fri Feb 18 10:10:18 CET 2000 0.2 -- Python syntax coloring in PDF

This is to announce the availability of py2pdf, a module to help
generate PDF files documenting Python source code in a nicely 
colored fashion. The current version is 0.2 and right now there 
are many shortcomings about lack of flexibility and program de-
sign. In fact, the resulting PDFs are much nicer than the code
itself, which should not come as a surprise with 0.2 being not
much more than a two day hack, disassembling Marc-Andre's nice
py2html and throwing it to Andy's PDFgen. 

I'm getting this out that early because I've been told several 
people would need PDF documentation support for Python source 
code. So I put most emphasis so far on getting some good-look-
ing output, maybe a bit too much. Therefor, please take it as 
a proof of concept rather than as a production quality module! 

I'm eager to get some feedback, but please don't expect me to 
be as responsive as those famous bots on comp.lang.python! 
Below you'll find some excerpts of the source comments.

You'll find py2pdf in my corner of the Starship Python:



py2pdf - 0.2

- Python syntax color highlighting in PDF
- fully visible whitespace such as blanks and tabs
- multi-line strings over page breaks rendered ok 
- plain text output including tags for debugging
- 100% pure Python, fully platform independent

- Python syntax color highlighting in PDF
- pretty-printing in a printer-friendly format
- teaching, reviewing, documenting Python code
- debugging Python code with indentation problems
- writing course material (sample solutions)
- providing initial printing engine to Python IDE developers
- providing 'uncorruptable' source code to publishers 
- writing code fragments to be used with pdflatex (not yet)

- JvR's PyFontify v. 0.3
- optionally Marc-Andre's mxTextTools
- Andy Robinson's PDFgen v. 2000-02-16 (using package structure)
  (likely, any newer version will do, like PDFgen-19991012,
  likely, pd2py will be distributed with PDFgen as a demo.)

- test stdin, stdout
- test CGI mode
- test parameter tag
- improve comments
- add support for monochrome display/printing
- move PDF formatting into class PrettyPrint and ...
- reorganise functions/classes...
- ... then add flexible bgcolor (now hard-wired only)
- ... then add support for paper formats other than A4
- ... then add time stamp to page decoration frame
- ... then switch on/off blank/tab rendering
- ... then add smart line wrapping
- reduce end user risk to accidentally use tags in their code
- implement -URL with PDF hyperlinks (postponed)
- support single-page PDF output in a page fraction (postponed)
- generalize/reunify with py2html, maybe (long term)
- what's next? py2opengl? ;-)

- get rid of the 'saved <file>' message
- fix buglet in PDFgen Odyssey demo
- add PDF hyperlinks (not there yet)
- add PDF outline/bookmarks (not there yet)

- misplaced tokens for blanks after inline strings
  (see especially function dummy())

Dinu C. Gherman
"The thing about Linux or open software in general is that 
it actually tries to move software from being witchcraft to 
being a science," [...] "A lot of the programs you see today 
are actually put together by shamans, and you just take it and 
if the computer crashes you walk around it three times... and 
maybe it's OK." (Linus Thorvalds, LinuxWorld 2000, NYC)

More information about the Python-list mailing list