You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
5 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
import os, datetime, sys
|
||
|
from argparse import ArgumentParser
|
||
|
from glob import glob
|
||
|
|
||
|
from PIL import Image
|
||
|
from reportlab.pdfgen import canvas
|
||
|
from reportlab.lib.pagesizes import *
|
||
|
from calibrestekje import Book, Publisher, init_session
|
||
|
|
||
|
# p = ArgumentParser("")
|
||
|
# p.add_argument("--output", default="poster.pdf")
|
||
|
# p.add_argument("--interpolation", default="cubic", help="nearest,cubic")
|
||
|
# p.add_argument("--labels", default="labels_public.txt")
|
||
|
# args = p.parse_args()
|
||
|
|
||
|
|
||
|
pagewidth, pageheight = landscape(A6)
|
||
|
|
||
|
c = canvas.Canvas("card_catalogue.pdf", pagesize=landscape(A6))
|
||
|
# x, y = 0, 0
|
||
|
# imagewidth = 200
|
||
|
# aw = pagewidth - imagewidth
|
||
|
# images = (glob ("images/*.JPG"))
|
||
|
# dx = aw/(len(images)-1)
|
||
|
# dy = 20
|
||
|
|
||
|
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()
|
||
|
# print (image)
|
||
|
# im = Image.open(image)
|
||
|
# pxwidth, pxheight = im.size
|
||
|
# print ("Got the image, it's size is:", im.size)
|
||
|
# imageheight = imagewidth * (pxheight / pxwidth)
|
||
|
# c.drawInlineImage(image, x, y, imagewidth, None)
|
||
|
# print ("placing image {0} at {1}".format(image, (x,y)))
|
||
|
# x += dx
|
||
|
# y += dy
|
||
|
|
||
|
c.save()
|
||
|
# sys.exit(0)
|
||
|
|
||
|
|
||
|
#################
|
||
|
# GRID
|
||
|
# imsize = 96
|
||
|
# cols = int(A0[0] // imsize)
|
||
|
# rows = int(A0[1] // imsize)
|
||
|
# # calculate margins to center the grid on the page
|
||
|
# mx = (A0[0] - (cols*imsize)) / 2
|
||
|
# my = (A0[1] - (rows*imsize)) / 2
|
||
|
# print ("Grid size {0}x{1} (cols x rows)".format(cols, rows))
|
||
|
# print (" (total size:", cols*imsize, rows*imsize, "margins:", mx, my, ")")
|
||
|
#################
|