reportlab/platypus/doctemplate.py
changeset 2083 52aae853f269
parent 1926 1c1f652b73d3
child 2098 57b8eadaf3de
equal deleted inserted replaced
2082:07bb9b9da8d9 2083:52aae853f269
     1 #copyright ReportLab Inc. 2000
     1 #copyright ReportLab Inc. 2000
     2 #see license.txt for license details
     2 #see license.txt for license details
     3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/doctemplate.py?cvsroot=reportlab
     3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/doctemplate.py?cvsroot=reportlab
     4 #$Header: /tmp/reportlab/reportlab/platypus/doctemplate.py,v 1.63 2003/05/11 11:01:30 rgbecker Exp $
     4 #$Header: /tmp/reportlab/reportlab/platypus/doctemplate.py,v 1.64 2003/10/06 11:31:09 rgbecker Exp $
     5 
     5 
     6 __version__=''' $Id: doctemplate.py,v 1.63 2003/05/11 11:01:30 rgbecker Exp $ '''
     6 __version__=''' $Id: doctemplate.py,v 1.64 2003/10/06 11:31:09 rgbecker Exp $ '''
     7 
     7 
     8 __doc__="""
     8 __doc__="""
     9 This module contains the core structure of platypus.
     9 This module contains the core structure of platypus.
    10 
    10 
    11 Platypus constructs documents.  Document styles are determined by DocumentTemplates.
    11 Platypus constructs documents.  Document styles are determined by DocumentTemplates.
   799     really accurate would be to do two passes, and I don't
   799     really accurate would be to do two passes, and I don't
   800     want to take that performance hit.
   800     want to take that performance hit.
   801     """
   801     """
   802     print 'PROGRESS MONITOR:  %-10s   %d' % (typ, value)
   802     print 'PROGRESS MONITOR:  %-10s   %d' % (typ, value)
   803 
   803 
   804 
       
   805     ##########################################################
       
   806     ##
       
   807     ##   testing
       
   808     ##
       
   809     ##########################################################
       
   810 
       
   811 def randomText():
       
   812     #this may or may not be appropriate in your company
       
   813     from random import randint, choice
       
   814 
       
   815     RANDOMWORDS = ['strategic','direction','proactive',
       
   816     'reengineering','forecast','resources',
       
   817     'forward-thinking','profit','growth','doubletalk',
       
   818     'venture capital','IPO']
       
   819 
       
   820     sentences = 5
       
   821     output = ""
       
   822     for sentenceno in range(randint(1,5)):
       
   823         output = output + 'Blah'
       
   824         for wordno in range(randint(10,25)):
       
   825             if randint(0,4)==0:
       
   826                 word = choice(RANDOMWORDS)
       
   827             else:
       
   828                 word = 'blah'
       
   829             output = output + ' ' +word
       
   830         output = output+'.'
       
   831     return output
       
   832 
       
   833 
       
   834 if __name__ == '__main__':
   804 if __name__ == '__main__':
   835 
   805 
   836     def myFirstPage(canvas, doc):
   806     def myFirstPage(canvas, doc):
   837         canvas.saveState()
   807         canvas.saveState()
   838         canvas.setStrokeColor(red)
   808         canvas.setStrokeColor(red)
   861 
   831 
   862         #need a style
   832         #need a style
   863         normal = ParagraphStyle('normal')
   833         normal = ParagraphStyle('normal')
   864         normal.firstLineIndent = 18
   834         normal.firstLineIndent = 18
   865         normal.spaceBefore = 6
   835         normal.spaceBefore = 6
       
   836         from reportlab.lib.randomtext import randomText
   866         import random
   837         import random
   867         for i in range(15):
   838         for i in range(15):
   868             height = 0.5 + (2*random.random())
   839             height = 0.5 + (2*random.random())
   869             box = XBox(6 * inch, height * inch, 'Box Number %d' % i)
   840             box = XBox(6 * inch, height * inch, 'Box Number %d' % i)
   870             objects_to_draw.append(box)
   841             objects_to_draw.append(box)