Share Pastebin
Guest
Public paste!

Roberto Alsina

By: a guest | Jun 4th, 2009 | Syntax: Python | Size: 0.83 KB | Hits: 27 | Expires: Never
Copy text to clipboard
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
  5. from reportlab.platypus.doctemplate import IndexingFlowable
  6. from reportlab.platypus.tableofcontents import TableOfContents
  7. from reportlab.lib.styles import getSampleStyleSheet
  8. from reportlab.rl_config import defaultPageSize
  9. from reportlab.lib.units import inch
  10. PAGE_HEIGHT=defaultPageSize[1]; PAGE_WIDTH=defaultPageSize[0]
  11. styles = getSampleStyleSheet()
  12.  
  13.  
  14. def go():
  15.     doc = SimpleDocTemplate("phello.pdf")
  16.     Story = [Spacer(1,2*inch),TableOfContents()]
  17.     style = styles["Normal"]
  18.     for i in range(10):
  19.         bogustext = ("This is Paragraph number %s. " % i) *20
  20.         p = Paragraph(bogustext, style)
  21.         Story.append(p)
  22.         Story.append(Spacer(1,0.2*inch))
  23.     doc.multiBuild(Story)
  24.  
  25. go()