[reportlab-users] UTF8 Encoded Strings

Rich Shepard rshepard at appl-ecosys.com
Wed Oct 31 16:39:32 EDT 2007


On Wed, 31 Oct 2007, Tim Roberts wrote:


> Hmmm, I'll give that some thought.


Thank you.


> Because when I started out typing that example, I had them all pass a

> canvas around, and I decided partway through that they should be members

> of a class instead, and I forgot to change that one. That isn't

> cut-and-pasted from a real-life example -- that's typed on the fly.


Oh. OK.


> Remember that the PDF file itself does not have the concept of a "cursor".

> That's strictly a by-product of the ReportLab text object, which I don't

> use, in part because of this confusion. For the canvas methods, which I

> use, every drawing function has to specify an X and a Y. Keeping track

> the location is entirely up to me.



> I agree that it is kind of confusing. It really looks like you are

> fighting the automatic tracking of the caret, and that you might be better

> off calling the canvas methods directly (drawString, drawRightString,

> drawCentredString). That would eliminate the conceptual issue of mixing

> canvas calls (i.e., line), which take effect immediately, and textobject

> calls (i.e., moveCursor) which don't take effect until canvas.drawText.


Aha! These two paragraphs answer the burning question I had; that is,
under what circumstances do I want to use canvas methods versus textobject
methods. Now I know to re-write once again using only the canvas functions.


> Also, I wanted to point out something that might be non-obvious:

>> ratingHead = """Importance

>> Value Definition

>> """

>>

>> ratingTab = """1 Equal importance

>> 3 Weak importance of one over the other

>> 5 Strong importance of one over the other

>> 7 Demonstrated importance of one over the other

>> 9 Absolute importance of one over the other

>> 2, 4, 6, 8 Intermediate values between the two adjacent definitions

>> """

>>

>> instructPara = """Using the table below, determine your preference for either the first

>> item of the pair (on the left), or the second (on the right). Use the

>> rating table to determine the strength of your preference, then fully

>> fill in the rectangle for that preference strenth on the same line as

>> the component pairs. If you prefer the second more than the first,

>> also completely fill in the last box on the right."""

>

> The indentation here becomes are part of the string. The first line of

> "ratingHead" has no leading white space. The second line starts with 20

> blanks. The third line consists of ONLY 20 blanks.


By design. This is how I tried to line them up on the pdf output.
Regardless of the leading blanks, there's no indentation in the output. I'll
see if I can correct this using the canvas rather than the textobject.

Many 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