it is easier if you create files, but here is how I do it all in memory:
# get pdf
pdf = mkpdf(ds,sample=True)
# render pdf onto pixbuf
pixbuf = Pixbuf(COLORSPACE_RGB,False,8,286,225)
doc = poppler.document_new_from_data(pdf,len(pdf),password='')
page0=doc.get_page(0)
page0.render_to_pixbuf(0,0,8,11,1,0,pixbuf)
# save pixbuf as png
# There has to be a better way to get the image?
lst=[]
pixbuf.save_to_callback(lambda b,l: l.append(b), 'png', user_data=lst)
png=''.join(lst)
return png
http://bazaar.launchpad.net/~mdipierro/web2conf/devel/annotate/head%3A/controllers/badge.py#L68
Works, but that .join() bothers me. I think it is because I feel like
I am using string/char functions on bytes. which are the same thing,
mostly.. but... I have issues.
--
Carl K
_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users
The sort of command that we end up running looks like this
C:\Program Files\gs\gs8.60\bin\gswin32c.exe -q -dSAFER -dNOPAUSE -dBATCH
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dJPEGQ=85
-sOutputFile=C:\Tmp\talpha2-page%04d.jpg -sDEVICE=jpeg -r9x9 -f talpha2.pdf
--
Robin Becker
that runs on a webserver. I didn't want to have to deal with write
permissions and multi user contention issues, so I keep the pdf and
png data in python vars. but it takes a few more lines of code,
including that .join() that makes me grumpy.
The code has been reviewed by a few people, and no one has suggested
there is anything wrong, so I am sure it is just fine. the comments
were more for anyone else that might know how to code it more
elegantly.
thanks
F