diff --git a/.gitignore b/.gitignore index f7275bb..da4150c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ venv/ +metadata.db diff --git a/simplelayout.py b/simplelayout.py index 023cff3..8c3807a 100644 --- a/simplelayout.py +++ b/simplelayout.py @@ -7,24 +7,41 @@ 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) - + rightMargin=18, leftMargin=18, + topMargin=0, 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) + print (book.authors) + # c.drawString(10,pageheight-10, book.title) # c.showPage() - p = Paragraph('{}'.format(book.title), styles["Normal"]) + + # create a paragraph and append content to it - e.g. book.title, book.authors etc + p = Paragraph('{}'.format(book.title), styles["Italic"]) + + content.append(p) + # content.append(PageBreak()) + content.append(Spacer(1, 12)) + + #import ipdb; ipdb.set_trace() + + format_string = '{}' + all_authors = [author.name for author in book.authors] + glued_together = format_string.format(", ".join(all_authors)) + + #if all_authors==['John Markoff']: + # import ipdb; ipdb.set_trace() + + p = Paragraph(glued_together, styles["Normal"]) content.append(p) - # content.append(Spacer(1, 12)) content.append(PageBreak()) + content.append(Spacer(1, 12)) -doc.build(content) +doc.build(content) \ No newline at end of file