from reportlab.lib.pagesizes import * from reportlab.pdfgen import canvas from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from calibrestekje import Book, Publisher, init_session pagewidth, pageheight = landscape(A6) doc = SimpleDocTemplate("text.pdf", pagesize=landscape(A6), rightMargin=72, leftMargin=72, topMargin=72, bottomMargin=18) content = [] styles = getSampleStyleSheet() session = init_session("sqlite:///metadata.db") # publisher = (session.query(Publisher) # .filter(Publisher.name == "MIT Press").one()) for book in session.query(Book).all(): print (book.title) # c.drawString(10,pageheight-10, book.title) # c.showPage() p = Paragraph('{}'.format(book.title), styles["Normal"]) content.append(p) # content.append(Spacer(1, 12)) content.append(PageBreak()) doc.build(content)