示例#1
0

##### DOCUMENT #####

# output file
output = 'pdf/'+__file__[:-3]+'.pdf'

# initialize PDF
pdf = Document(output, title='Example')

# create your own elements styles
h1    = pdf._text(font='Helvetica-Bold', size=20, color='#17365d')
p     = pdf._text(font='Times-Roman')
pre   = pdf._text(font='Courier',preformatted=True)
tbl   = pdf._table()
img   = pdf._image()

# start page applying a specific layout "firstCover"
pdf.page(layout=firstCover)

# change padding for next pages by setting all to 40 points
pdf.padding(left=20,right=20,top=20,bottom=20)

# start a page with :
#- no layout set
#- a background color #e6eeee
#- keeping the previous padding above: left = right = top = bottom = 40
#- a flow of text elements: h1 followed by p
pdf.page(
  h1('About This Document'),
  p('This document explains my attempt to wrap the current Reportlab Toolkit API in order to make PDFs easily.'),