Roberto Alsina
By: a guest | Jun 4th, 2009 | Syntax:
Python | Size: 0.83 KB | Hits: 27 | Expires: Never
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.platypus.doctemplate import IndexingFlowable
from reportlab.platypus.tableofcontents import TableOfContents
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.rl_config import defaultPageSize
from reportlab.lib.units import inch
PAGE_HEIGHT=defaultPageSize[1]; PAGE_WIDTH=defaultPageSize[0]
styles = getSampleStyleSheet()
def go():
doc = SimpleDocTemplate("phello.pdf")
Story = [Spacer(1,2*inch),TableOfContents()]
style = styles["Normal"]
for i in range(10):
bogustext = ("This is Paragraph number %s. " % i) *20
p = Paragraph(bogustext, style)
Story.append(p)
Story.append(Spacer(1,0.2*inch))
doc.multiBuild(Story)
go()