[reportlab-users] Can you help my Reportlab program?

Robin Becker robin at reportlab.com
Tue Oct 13 07:37:47 EDT 2015


Hi 方建,

You will reach a wider audience if you join the reportlab-users list

https://pairlist2.pair.net/mailman/listinfo/reportlab-users


However, I think I may be able to assist you.

1) The Paragraph class is designed to cooperate with the Frame/DocTemplate 
classes and is a sub-class of Flowable.

2) Normally the Paragraph is instantiated, wrapped and then drawn. The wrap 
method allows the user to specify how much space is available and also determine 
how much space will be used. The draw method then allows the user to determine 
whether or not the paragraph should be drawn at the current point in the Frame.


3) More concretely

    pa = Paragraph('some texts........', some_style)
    w, h = pa.wrap(availableWidth,availableHeight)
    # w and h now hold the width and height that the paragraph expects to use
    # *NB* when you draw the paragraph it will take the coordinates you give
    # to the draw method as the left lower corner of a w x h rectangle

    # to get the top left corner at 370, 225 we have to subtract h from 225
    pa.draw(canvas,370,225-h)

hope this helps
-- 
Robin Becker
On 13/10/2015 10:28, 方建 wrote:
> hi:
> I use the Reportlab to generate the pdf. I use Paragraph,but the Pa.drawOn(canvas, 370, 225) method draw not start the first line at (370, 225),
> butthe last line start at (370, 225), how can I draw every first fine at (370, 225)?
>
> thank you for your help!!!
>
> 2015-10-13
>

>
> 方建
> 网易(广州)在线游戏事业部平台服务部
> 18717194808
> fjn3304 at corp.netease.com
>




More information about the reportlab-users mailing list