|
|
@ -1,14 +1,19 @@ |
|
|
|
from calibrestekje import Book, Comment, Publisher, init_session |
|
|
|
from reportlab.lib.pagesizes import * |
|
|
|
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet |
|
|
|
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, Comment, init_session |
|
|
|
from reportlab.platypus import PageBreak, Paragraph, SimpleDocTemplate, Spacer |
|
|
|
|
|
|
|
pagewidth, pageheight = landscape(A6) |
|
|
|
|
|
|
|
doc = SimpleDocTemplate("text.pdf", pagesize=landscape(A6), |
|
|
|
rightMargin=18, leftMargin=18, |
|
|
|
topMargin=0, bottomMargin=18) |
|
|
|
doc = SimpleDocTemplate( |
|
|
|
"text.pdf", |
|
|
|
pagesize=landscape(A6), |
|
|
|
rightMargin=18, |
|
|
|
leftMargin=18, |
|
|
|
topMargin=0, |
|
|
|
bottomMargin=18, |
|
|
|
) |
|
|
|
|
|
|
|
content = [] |
|
|
|
styles = getSampleStyleSheet() |
|
|
@ -27,18 +32,19 @@ for book in session.query(Book).all(): |
|
|
|
print(book.tags) |
|
|
|
print(comment.text) |
|
|
|
|
|
|
|
|
|
|
|
# create a paragraph and append content to it - e.g. book.title, book.authors etc |
|
|
|
ptitle = Paragraph('<font size=12>{}</font>'.format(book.title), styles["Italic"]) |
|
|
|
ptime = Paragraph('<font size=10>Uploaded: {}</font>'.format(book.timestamp), styles["Normal"]) |
|
|
|
pcomments = Paragraph('<font size=10>{}</font>'.format(comment.text)) |
|
|
|
ptitle = Paragraph("<font size=12>{}</font>".format(book.title), styles["Italic"]) |
|
|
|
ptime = Paragraph( |
|
|
|
"<font size=10>Uploaded: {}</font>".format(book.timestamp), styles["Normal"] |
|
|
|
) |
|
|
|
pcomments = Paragraph("<font size=10>{}</font>".format(comment.text)) |
|
|
|
|
|
|
|
# list comprehensions for authors and tags |
|
|
|
format_string = '<font size=12>{}</font>' |
|
|
|
format_string = "<font size=12>{}</font>" |
|
|
|
all_authors = [author.name for author in book.authors] |
|
|
|
glued_together = format_string.format(", ".join(all_authors)) |
|
|
|
|
|
|
|
format_string = '<font size=10>{}</font>' |
|
|
|
format_string = "<font size=10>{}</font>" |
|
|
|
all_tags = [tag.name for tag in book.tags] |
|
|
|
tags_glued_together = format_string.format(", ".join(all_tags)) |
|
|
|
|
|
|
|