[reportlab-users] Generate a Jpeg image from a PDF File done by reportlab

Dani Reguera dreguera at tagzania.com
Wed Dec 2 11:41:50 EST 2009



>it is easier if you create files, but here is how I do it all in memory:



Hi Carl,

The pdf contents are images and text, but this images is generated by my. I
have this images in my pc and only I put them in the canvas.

How could I do in a easier way?

Thx so much

2009/12/2 Carl Karsten <carl at personnelware.com>


> On Wed, Dec 2, 2009 at 10:07 AM, Dani Reguera <drbakhache at gmail.com>

> wrote:

> > Hi everybody,

> >

> > I have a problem with a pdf file generated with reportlab, maybe anyone

> > could help me. I have generated a file in reportlab, and now I want to

> make

> > a thumbnail image, the format doesn't matter (png or jpeg) and I'm

> trying

> > with ghostscript (GS) and ImageMagick, but the problem is that GS tells

> me

> > that it's and error. Seems that the pdf generated by reportlab is

> > corrupted... could be that the pdf format is PDF-1.3?

> >

> > Is in reportlab a way to generate a jpg image or export apdf file to a

> jpg

> > image?

> >

> > Any suggestion or help will be appreciated.

> >

>

> 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<http://bazaar.launchpad.net/%7Emdipierro/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

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

>




--

Dani Reguera
dreguera at tagzania.com

Tagzania Services [www.tagzania-services.com]
Azitaingo Industrialdea 3 K
E-20600 Eibar
Tel: (+34) 943 82 17 80
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20091202/cc82a6a2/attachment.html>


More information about the reportlab-users mailing list