[reportlab-users] Insert a chart in a pdf...

Andy Robinson reportlab-users@reportlab.com
Wed, 17 Jul 2002 20:45:19 +0100


Marcus,

In addition to adding a drawing to a story, you can
also explicitly draw them in pdfgen mode.  renderPDF
contains this function:

def draw(drawing, canvas, x, y, showBoundary=rl_config.showBoundary):
    """As it says"""

In graphics
generally, we have assumed a scale of 1 point = 1 pixel;
so if you are designing a chart to be 200 'units'
then it will be 200 points wide on the canvas.
You can use the canvas translate/scale methods before
drawing it to shrink or enlarge things if you need to,
but when using it in a story you should probably
'draw it the right size' to start with.


Your questions pointed out to me that we had not properly
documented these things in the graphics guide
(docs/graphguide.pdf); we've got someone starting on a
rewrite and will make sure we add more on how to use the renderers
in chapter 2.

Thanks,

Andy Robinson


-----Original Message-----
From: reportlab-users-admin@reportlab.com
[mailto:reportlab-users-admin@reportlab.com]On Behalf Of Marcus Vinicius
Laranjeira
Sent: 17 July 2002 20:18
To: reportlab-users@reportlab.com
Subject: Re: [reportlab-users] Insert a chart in a pdf...


Robin,

Nevermind... it worked fine !!!!

Thanks !

At 15:26 17/07/02 -0300, you wrote:

Robin,

I will try this... and, how about the size of the drawing !? if it does not
fit the space I have, how do I scale it down !? with an image I can do
something like this:
.
.
.
img = Image("someimage.jpg")
img.drawHeight = 300
img.drawWidth = 300
story.append(img)
.
.
.

But how about raw drawings !?

Thanks,

Marcus


At 19:18 17/07/02 +0100, Robin Becker wrote:

In article <5.1.1.6.0.20020717145918.009fb010@imap.datacraft.com.br>,
Marcus Vinicius Laranjeira <m.laranjeira@datacraft.com.br> writes
>
>
>All,
>
>I have one doubt... I am inserting some charts in a pdf using a frame and
>some page templates,.... but the images seems to loose resolution when they
>are inserted in the flowable...
>
>I think that the process I am doing this is wrong:
>
>1- I create the pdf canvas and I add a frame on it
>2- I create the graphic in a drawing and render it as a png (I tryed with
>all kind of graphic type supported by pil)
>3- I add the graphic file to the frame... (sometimes I need to resize it so
>it can fit)
>
>Is there a way to insert the drawing directly on the frame flowable instead
>of creating a file and then inserting this file in the frame !?
>
>Thanks a lot,
>
>Marcus
.......
You don't need to render to PNG to get the PDF framework to handle stuff
properly. You need just create the Drawing instance. Drawings are
themselves flowables so you can just append the drawing to the story in
the right place.
--
Robin Becker
_______________________________________________
reportlab-users mailing list
reportlab-users@reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users




Marcus Vinicius Laranjeira
MON Center

Datacraft do Brasil - (http://www.datacraft.com.br)
R. Tenente Negrão, 140 - 8o. Andar
Itaim Bibi - São Paulo - SP - 04530-030
Tel: +55-11-3053-0241
Fax: +55-11-3053-0220



Marcus Vinicius Laranjeira
MON Center

Datacraft do Brasil - (http://www.datacraft.com.br)
R. Tenente Negrão, 140 - 8o. Andar
Itaim Bibi - São Paulo - SP - 04530-030
Tel: +55-11-3053-0241
Fax: +55-11-3053-0220