Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fpdf import FPDF
- lists = [['a.html', 'b.html', 0, '[x,y]'], ['c.qbl', 'p.mbl', 'q.dbl']]
- # Method 1 - printing inside the list
- def createPDF(lists) :
- c = ""
- pdf=FPDF()
- pdf.add_page()
- pdf.set_font('Arial','B',16)
- pdf.cell(10,10, "") # telling where the first line is- Note: not necessary
- # loop to fetch the list :
- for i in lists:
- for j in i :
- pdf.cell(10,20 ,str(j) )
- pdf.ln(20)
- pdf.output('tuto3.pdf', 'F')
- createPDF(lists)
- # Method 2 - printing without loop: used in complex processing
- #helper function to process a list
- def createPrintableList(lists,c):
- # processing list
- for i in lists:
- for j in i :
- c = c + " " + str(j) # cocatenating list elements
- return c
- def createPDF(lists) :
- c = ""
- pdf=FPDF()
- pdf.add_page()
- pdf.set_font('Arial','B',16)
- c = createPrintableList(lists, c) # calling function to process list
- pdf.cell(10, 10, c)
- pdf.output('tuto4.pdf', 'F')
- print createPDF(lists)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement