PIL and PSDraw
Sybren Stuvel
sybrenUSE at YOURthirdtower.com.imagination
Wed Mar 1 03:43:31 EST 2006
Hi there,
I'm experimenting with PIL to create a PostScript file. The end result
should be an EPS file with a couple of bar graphs.
At this moment, I have a very simple piece of code:
ps = PIL.PSDraw.PSDraw(file('demo.ps', 'w'))
ps.begin_document()
ps.rectangle((0, 0, 650, 150))
ps.end_document()
Unfortunately, when looking at 'demo.ps' using ghostview, I see an
empty page. This feeling of 'emptyness' is augmented by 'ps2epsi',
which tells me:
$ ps2epsi demo.ps
blank page!!
Can anyone tell me what I'm doing wrong? I've just started to use PIL,
so if there is something better to create EPS files, please let me
know!
Sybren
The contents of demo.ps:
======================================================================
%!PS-Adobe-3.0
save
/showpage { } def
%%EndComments
%%BeginDocument
/S { show } bind def
/P { moveto show } bind def
/M { moveto } bind def
/X { 0 rmoveto } bind def
/Y { 0 exch rmoveto } bind def
/E { findfont
dup maxlength dict begin
{
1 index /FID ne { def } { pop pop } ifelse
} forall
/Encoding exch def
dup /FontName exch def
currentdict end definefont pop
} bind def
/F { findfont exch scalefont dup setfont
[ exch /setfont cvx ] cvx bind def
} bind def
/Vm { moveto } bind def
/Va { newpath arcn stroke } bind def
/Vl { moveto lineto stroke } bind def
/Vc { newpath 0 360 arc closepath } bind def
/Vr { exch dup 0 rlineto
exch dup neg 0 exch rlineto
exch neg 0 rlineto
0 exch rlineto
100 div setgray fill 0 setgray } bind def
/Tm matrix def
/Ve { Tm currentmatrix pop
translate scale newpath 0 0 .5 0 360 arc closepath
Tm setmatrix
} bind def
/Vf { currentgray exch setgray fill setgray } bind def
%%EndProlog
0 0 M 650 150 0 Vr
%%EndDocument
restore showpage
%%End
======================================================================
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
More information about the Python-list
mailing list