Import Module ดังต่อไปนี้
โค้ด: เลือกทั้งหมด
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch
from reportlab.platypus import Paragraph, Frame
โค้ด: เลือกทั้งหมด
styles = getSampleStyleSheet()
styleN = styles['Normal']
styleH = styles['Heading1']
story = []
โค้ด: เลือกทั้งหมด
#add some flowables
story.append(Paragraph("Example",styleH))
story.append(Paragraph("Hello every one!!",
styleN))
c = Canvas('mydoc.pdf')
f = Frame(inch, inch, 6*inch, 9*inch, showBoundary=1)
f.addFromList(story,c)
c.save()