[reportlab-users] bullet

Jean-Yves F. Barbier 12ukwn at gmail.com
Wed Jan 25 15:58:53 EST 2012


On Wed, 25 Jan 2012 11:58:57 -0800
Tim Roberts <timr at probo.com> wrote:


> Jean-Yves F. Barbier wrote:

> > I can't use <bullet> because my text is a big monolithic paragraph;

> > so, is there a possibility to introduce a line break within my §?

>

> I'm not sure how those two clauses are related. If you need a line

> break, then what you have is a new paragraph.

>

> Perhaps you could be more specific, like showing an example of what you

> want.


Ok, my data come from one column of a database, this is what I call
monolithic: only one big block of text.

Everything is transformed into a Paragraph and these Paragraphs goes
into Table cells with multiple columns.

Actually, at this time I use a kinda dictionary to store my test
data and simulate the DB read:
self.cieInfo = Storage(
cial = "My Name", adr2 = "Bergamotte Straße 12", etc...
and
self.docLines = []
self.docLines.append( Storage( code=u"CAREFTP6", des=u"Câble réseau cat. FTP 6",
desl=None, desl_print=False, comment=None,
unit_price=Decimal('1.20'), unit=u"ml", qty=Decimal('3.00'), rebate=Decimal('0.0000'),
total_price=Decimal('3.60'), vatc=1 ) )
.....

In method, I do something like:
de = self.docLines[i].des
dl = self.docLines[i].desl
dp = self.docLines[i].desl_print
co = self.docLines[i].comment
c1 = []
if de is not None:
des = Paragraph(de, docItemListCol1des)
c1.append(des)
if dp:
if dl is not None:
desl = Paragraph(dl, docItemListCol1desl, bulletText="©")
c1.append(desl)
......
ilt = Table( self.items_list, [ ITEMS_COL0_W, ITEMS_COL1_W, ITEMS_COL2_W, ITEMS_COL3_W, ITEMS_COL4_W,
ITEMS_COL5_W, ITEMS_COL6_W, ITEMS_COL7_W ] )
# NB: As we pile Paragraphs and not strings, the alignment
# that works is into the Paragraphs styles, NOT here!
ilt.setStyle(TableStyle([('VALIGN', (0, 0), (-1, -1), 'TOP'), # ALL
('LEFTPADDING', (0, 0), (-1, -1), 2), # ALL
('RIGHTPADDING', (0, 0), (-1, -1), 2), # ALL
('TOPPADDING', (0, 0), (-1, -1), 0), # ALL
('BOTTOMPADDING', (0, 0), (-1, -1), 3), # ALL
# Table in enclosed in a box
('BOX', (0, 0), (-1, -1), 0.50, colors.black),
# HLine under Titles
('LINEBELOW', (0, 0), (-1, 0), 0.50, colors.black),
# Vlines to the right of Each Column (inc. Titles)
#('LINEAFTER', (0, 0), (-2, -1), 0.05, colors.black),
# Vlines to the right of Titles (only)
#('LINEAFTER', (0, 0), (-1, 0), 0.05, colors.black),
# Vlines to the right of Items Columns (excl. Titles)
('LINEAFTER', (0, 1), (-1, -1), 0.05, colors.black),
]))

What I'd like is (sometimes) to separate large block of text ('des',
'desl' or 'comment') by separating them with at least a line break
avoiding the use of a special char to discriminate them, such as:
if desl.count("…") != 0:
cut string into multiple strings @ "…"
make Paragraphs with those strings
put Paragraphs into Table's cells

If there's no <tag> solution, I'll do it this way.

Bullets would be great, but it failed, even with only one line:
bullet appears BUT text isn't wrap to Table column width (it
overwrites right columns and even get out of page).

I also see there's another Paragraph into lib/para.py which
interest me a lot (for <ul><li>, ...) but it fail to replace
the regular one:(

from reportlab.platypus.para import Para as Paragraph
........
Traceback (most recent call last):
File "create_doc_pdf__2012-01-25_01.py", line 2008, in <module>
ERPpdf( dbUserId, docType, docCliSup, docId, cursor=u"None" )
File "create_doc_pdf__2012-01-25_01.py", line 371, in __init__
self.docCie()
File "create_doc_pdf__2012-01-25_01.py", line 504, in docCie
data = [[ Paragraph(self.cieInfo.cial, docCieName) ]]
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/para.py", line 1231, in __init__
self.spaceBefore = style.spaceBefore
AttributeError: 'unicode' object has no attribute 'spaceBefore'

--
Q: What's red and covered with little dents?
A: Snow White's cherry.


More information about the reportlab-users mailing list