[reportlab-users] Another problem -- pdfgen\textObject
Dave Rogers
reportlab-users@reportlab.com
Fri, 13 Dec 2002 14:15:19 -0500
--------------0440CCE3EE7262BA4B619486
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Thanks for the quick reply Robin re the drawImage.
I'm also having another problem -- this one with pdfgen\textObject.py
Based on my understanding, if I send a trim=0, no whitespace should be removed.
However, I noticed that the code removes leading whitespace on string types (which is a problem for me) even with a trim=0.
I have edited my local version to be this (see the comment with the 'dr' in it -- that's what I added to preserve leading whitespace):
def textLines(self, stuff, trim=1):
"""prints multi-line or newlined strings, moving down. One
comon use is to quote a multi-line block in your Python code;
since this may be indented, by default it trims whitespace
off each line and from the beginning; set trim=0 to preserve
whitespace."""
if type(stuff) == StringType:
if trim==1:
lines = string.split(string.strip(stuff), '\n')
else:
lines = string.split(stuff, '\n') # preserve leading white space dr 10-31-02
if trim==1:
lines = map(string.strip,lines)
elif type(stuff) == ListType:
lines = stuff
elif type(stuff) == TupleType:
lines = stuff
else:
assert 1==0, "argument to textlines must be string,, list or tuple"
for line in lines:
self._code.append('%s T*' % self._formatText(line))
if self._canvas.bottomup:
self._y = self._y - self._leading
else:
self._y = self._y + self._leading
self._x = self._x0
Any idea if this will be corrected in 1.17?
Thanks,
--
Dave Rogers
DaveRogers@StockAlerts.com
http://StockAlerts.com
--------------0440CCE3EE7262BA4B619486
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Thanks for the quick reply Robin re the drawImage.
<p>I'm also having another problem -- this one with pdfgen\textObject.py
<p>Based on my understanding, if I send a trim=0, no whitespace should
be removed.
<p>However, I noticed that the code removes leading whitespace on string
types (which is a problem for me) even with a trim=0.
<p>I have edited my local version to be this (see the comment with the
'dr' in it -- that's what I added to preserve leading whitespace):
<p><tt> def textLines(self, stuff, trim=1):</tt>
<br><tt> """prints multi-line
or newlined strings, moving down. One</tt>
<br><tt> comon use is to quote
a multi-line block in your Python code;</tt>
<br><tt> since this may be indented,
by default it trims whitespace</tt>
<br><tt> off each line and from
the beginning; set trim=0 to preserve</tt>
<br><tt> whitespace."""</tt>
<br><tt> if type(stuff) == StringType:</tt>
<br><tt>
if trim==1:</tt>
<br><tt>
lines = string.split(string.strip(stuff), '\n')</tt>
<br><tt>
else:</tt>
<br><tt>
lines = string.split(stuff, '\n') # preserve leading white space dr 10-31-02</tt>
<br><tt>
if trim==1:</tt>
<br><tt>
lines = map(string.strip,lines)</tt>
<br><tt> elif type(stuff) ==
ListType:</tt>
<br><tt>
lines = stuff</tt>
<br><tt> elif type(stuff) ==
TupleType:</tt>
<br><tt>
lines = stuff</tt>
<br><tt> else:</tt>
<br><tt>
assert 1==0, "argument to textlines must be string,, list or tuple"</tt><tt></tt>
<p><tt> for line in lines:</tt>
<br><tt>
self._code.append('%s T*' % self._formatText(line))</tt>
<br><tt>
if self._canvas.bottomup:</tt>
<br><tt>
self._y = self._y - self._leading</tt>
<br><tt>
else:</tt>
<br><tt>
self._y = self._y + self._leading</tt>
<br><tt> self._x = self._x0</tt>
<p>Any idea if this will be corrected in 1.17?
<p>Thanks,
<br>--
<br>Dave Rogers
<br>DaveRogers@StockAlerts.com
<br><A HREF="http://StockAlerts.com">http://StockAlerts.com</A>
<br> </html>
--------------0440CCE3EE7262BA4B619486--