27 lines
844 B
Python
27 lines
844 B
Python
"""Small PDF builder for the metadata and fetch tests (needs reportlab, which the CI unit-test step installs)."""
|
|
from reportlab.lib.pagesizes import letter
|
|
from reportlab.pdfgen import canvas
|
|
|
|
|
|
def make_pdf(path, pages, title=None, author=None):
|
|
"""pages: list of lists of text lines; an empty list = a page with only a picture-like box (no text layer)."""
|
|
c = canvas.Canvas(path, pagesize=letter)
|
|
if title:
|
|
c.setTitle(title)
|
|
if author:
|
|
c.setAuthor(author)
|
|
for lines in pages:
|
|
y = 700
|
|
if not lines:
|
|
c.rect(100, 100, 300, 400, fill=1)
|
|
for ln in lines:
|
|
if ln == "":
|
|
y -= 30
|
|
continue
|
|
c.setFont("Helvetica", 18)
|
|
c.drawString(100, y, ln)
|
|
y -= 24
|
|
c.showPage()
|
|
c.save()
|
|
return path
|