def _ptoTestCase(self): """PTO stands for Please Turn Over and is a means for specifying content to be inserted when stuff goes over a page. This makes one long multi-page paragraph.""" # Build story. story = [] def fbreak(story=story): story.append(FrameBreak()) styleSheet = getSampleStyleSheet() H1 = styleSheet['Heading1'] H1.pageBreakBefore = 0 H1.keepWithNext = 0 bt = styleSheet['BodyText'] pto = ParagraphStyle('pto',parent=bt) pto.alignment = TA_RIGHT pto.fontSize -= 1 def ColorParagraph(c,text,style): return Paragraph('<para color="%s">%s</para>' % (c,text),style) def ptoblob(blurb,content,trailer=None,header=None, story=story, H1=H1): if type(content) not in (type([]),type(())): content = [content] story.append(PTOContainer([Paragraph(blurb,H1)]+list(content),trailer,header)) t0 = [ColorParagraph('blue','Please turn over', pto )] h0 = [ColorParagraph('blue','continued from previous page', pto )] t1 = [ColorParagraph('red','Please turn over(inner)', pto )] h1 = [ColorParagraph('red','continued from previous page(inner)', pto )] ptoblob('First Try at a PTO',[Paragraph(text0,bt)],t0,h0) fbreak() c1 = Table([('alignment', 'align\012alignment'), ('bulletColor', 'bulletcolor\012bcolor'), ('bulletFontName', 'bfont\012bulletfontname'), ('bulletFontSize', 'bfontsize\012bulletfontsize'), ('bulletIndent', 'bindent\012bulletindent'), ('firstLineIndent', 'findent\012firstlineindent'), ('fontName', 'face\012fontname\012font'), ('fontSize', 'size\012fontsize'), ('leading', 'leading'), ('leftIndent', 'leftindent\012lindent'), ('rightIndent', 'rightindent\012rindent'), ('spaceAfter', 'spaceafter\012spacea'), ('spaceBefore', 'spacebefore\012spaceb'), ('textColor', 'fg\012textcolor\012color')], style = [ ('VALIGN',(0,0),(-1,-1),'TOP'), ('INNERGRID', (0,0), (-1,-1), 0.25, black), ('BOX', (0,0), (-1,-1), 0.25, black), ], ) ptoblob('PTO with a table inside',c1,t0,h0) fbreak() ptoblob('A long PTO',[Paragraph(text0+' '+text1,bt)],t0,h0) fbreak() ptoblob('2 PTO (inner split)',[ColorParagraph('pink',text0,bt),PTOContainer([ColorParagraph(black,'Inner Starts',H1),ColorParagraph('yellow',text2,bt),ColorParagraph('black','Inner Ends',H1)],t1,h1),ColorParagraph('magenta',text1,bt)],t0,h0) _showDoc('test_platypus_pto.pdf',story)
def ptoblob(blurb, content, trailer=None, header=None, story=story, H1=H1): if type(content) not in (type([]), type(())): content = [content] story.append( PTOContainer([Paragraph(blurb, H1)] + list(content), trailer, header))