[reportlab-users] UTF8 Encoded Strings

Rich Shepard rshepard at appl-ecosys.com
Wed Oct 31 15:29:57 EDT 2007


On Wed, 31 Oct 2007, Tim Roberts wrote:


> Printing is a tedious task, and there's just no way around it. We all get

> spoiled by programs like Word and OpenOffice that let us lay out text

> free-form, but when it comes to programmatically sticking pixels on paper,

> someone had to keep track of where every character and line gets placed.

> Personally, I like it that way. ;)


Tim,

I've been using LaTeX and LyX for most of my writing the past half-dozen
or so years, and writing UIs (in C and python) is also tedious. That doesn't
bother me as much as not fully understanding how to use ReportLab now.


> I often create my own version of the textobject class that keeps track of

> the things that need tracking. I will usually have TextOut, which draws a

> string and remembers where it ended, and TextOutLine that draws a string

> and moves the cursor to the start of the next line. I sometimes have

> Indent and Dedent methods to temporarily bump the left margin. I do an

> awful lot of business forms in ReportLab, so I have some versions that do

> automatic dot fill or underline fill for tables. I have some versions that

> insert check boxes. I have some versions that automatically underline the

> string.


Are these available for reuse by others ... particularly me? :-)


> I try to collect each section of the page into a function. Then I'll

> have something like:

>

> def drawLeftHandSide( self, left, top, width, height ):

> # Each piece returns its "bottom". That becomes the next "top".

> top = self.drawCorporateLogo( left, top, width, height )

> top -= inch / 4

> top = self.drawTopSummary( left, top, width, height )

>

> def drawRightHandSide( canvas, left, top, width, height ):

> ...

>

> def drawFrontPage( self, left, top, width, height ):

> self.drawLeftHandSide( left, top, width/2, height )

> self.drawRightHandSide( left+width/2, top, width/2, height )


Why does drawRightHandSide reference the canvas while the other two
reference self?

I suppose that I should partition the report I'm currently developing into
the three sections, and call each as a separate function.

What I really need to learn better is understanding where the cursor is at
all times, and where text will print relative to that. I get the impression
from my trial-and-error development today that the cursor remains at the
lead of a block of printed text rather than at the end. Of course, I may
well be totally wrong ... it wouldn't be the first time.

Now that the file is actually attached to a message, if you have time to
comment on it that would be very helpful.

Thanks,

Rich

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863


More information about the reportlab-users mailing list