[DB-SIG] platypus Code

M.-A. Lemburg mal at egenix.com
Wed Feb 22 14:53:34 CET 2006


Rasha Ebo wrote:
> Peace be upon you,

Thanks, but I think you posted this to the wrong mailing list. db-sig
is about relational databases. You question sounds more related to
ReportLab's PDF lib.

>   I use the platypus example in reportlab's user guide chapter 5 page 59 to build up a Doctemplate with flowables 'paraghrap' and 'spacer' (it is used to create 100 fixed-content paraghrap with spacer between paragraphs) and it worked well then I added to this example, the code of the 'Table' follwable in page 73 chapter 7 which used a variable called 'data' to hold the data of the table (code is provided at the end)
>    
>   When the value of data is:
>       data= [['00', '01', '02', '03', '04'],
>                ['10', '11', '12', '13', '14'],
>                ['10', '11', '12', '13', '14'],
>                ['30', '31', '32', '33', '34']]
>      and  no of the repeating the paraghraphes wsa set to 100
>    , an error was raised saying:
>    
>   reportlab.platypus.doctemplate.LayoutError: Flowable <Table at 11499960 4 rows x 5 cols> with cell(0,0) containing '00' too large on page 13
>    
>   At the begining, I thought it is a problem of splitting table across multiple pages but it is not because when I changed the value of data to be:
>    
>       data= [['00', '01', '02', '03', '04'],
>                ['10', '11', '12', '13', '14']]
>   and kept the  no of the repeating the paraghraphes the same as above (100 times)
>   , No error has been raised and a table was splitted perfectly across 2 pages
>    
>   then I changed the data value to be:
>    
>       data= [['00', '01', '02', '03', '04'],
>                ['10', '11', '12', '13', '14'],
>                ['10', '11', '12', '13', '14'],
>                ['30', '31', '32', '33', '34']]
>   but I changed the no of the repeating the paraghraphes to 54 or less and it works well but with 55 or more, it fails.
>   And by more experiments I have found that if cut down the length of the table data and increase the repetition number of the paragraph, it can work well and viseversa
>    
>   Can anybody  explain to me what is the point that rules this behaviour, is it the number of charcters per page or per table cell or what?
>    
>   I will highlight the code line which sets the value of the table and the cosde line which determines the no of repetition
>    
>    I hope I have made my question clear and thanks very much for yor help
>   (N.B I am a newbebi)
>    
>   Thanks a lot
>    
>   Code:
>    
>   platypusgo = """
> def go():
>     doc = SimpleDocTemplate("phello.pdf")
>       Story = [Spacer(1,2*inch)]
>     style = styles["Normal"] 
>       data= [['00', '01', '02', '03', '04'],
>                ['10', '11', '12', '13', '14'],
>                ['10', '11', '12', '13', '14'],
>                ['30', '31', '32', '33', '34']]
>     t=Table(data)
>     t.setStyle(TableStyle([('BACKGROUND',(1,1),(1,-1),green),('TEXTCOLOR',(0,0),(1,-1),red)]))
>     for i in range(100):
>         bogustext = ("This is Paragraph number %s.  " % i) *20
>         p = Paragraph(bogustext, style)
>           Story.append(p)
>           Story.append(Spacer(1,0.2*inch))
>         Story.append(t)
>     doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages) #Finally build up your DocTemplate
> """
>    
>   #------------Execute the page code-----------------------------------
> if __name__=="__main__":
>     # then do the platypus hello world
>     for b in platypussetup, platypusfirstpage, platypusnextpage, platypusgo:
>         b = strip(b)
>         print b
>         exec(b+'\n')
>     go()
> 
> 			
> ---------------------------------
>  Yahoo! Mail
>  Use Photomail to share photos without annoying attachments.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> DB-SIG maillist  -  DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Feb 22 2006)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the DB-SIG mailing list