from wrapper import Document, landscape, A4 output = 'pdf/'+__file__[:-3]+'.pdf' # open a A4 document in landscapte and with no paddings pdf = Document(output, title='Configure a page', pagesize=landscape(A4)) # create a new page : # set a background color # override paddings from 0 to 10 # override pagesize from landscape to portrait pdf.page(color='#336391', left=10, right=10, top=10, bottom=10, pagesize=A4) # save and close pdf.close()
# 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.'), img('images/reportlab.gif'), color='#e6eeee' )