making postscript of pdf files

George Demmy gdemmy at layton-graphics.com
Fri May 10 09:24:06 EDT 2002


"Jonathan Vanasco" <jvanasco at hotmail.com> writes:

> i'm hoping to write a python script to make some daily stats stuff
> into a (preferably) postscript file, or possibly a pdf or tiff image.
> Just really to get the text on there underneath a standard header.
> 
> 
> I could find 1,000,000 leads on how to do this in perl , but i'd
> rather attempt this in python first.
> 
> 
> Can anyone give me some tips/pointers?

There's a bunch of stuff out there... and if you want to do nifty
stuff, check out http://www.reportlab.com for a thorough Python-based
pdf solution.

However, if you are just looking to do some simple, one off stuff, why
not just write postscript directly? This is some *minimal* postscript
to get you going:

/Helvetica findfont 18 scalefont setfont
100 500 moveto
(My Header) show
100 400 moveto
(3.14159) show
showpage

This is not a paragon of PostScript, it's just a "proof of concept".
Extension to Python is straight forward by creating an interface to
these functions e.g.,

def font(font='Helvetica',scale=18):
  return '/%s findfont %d scalefont setfont' % (font, scale)

Postscript is a nifty programming language that is fun to learn in its
own right. The PostScript Language Reference Manual is available from
http://www.adobe.com and there are a bunch of postscript tutorials if
you want more info. PDF is *much* more of a hassle, especially
implementing "document generators* from the ground up (don't do it,
use reportlab). PDF is more useful at the document level. Plus, you
can always convert PS to PDF. Stay way way way away from creating
raster images to display your *textual* information. Also, if you want
to make graphs, you can produce encapsulated postscript with graphing
programs (e.g., gnuplot).

G



More information about the Python-list mailing list