Metadata never fails a drop: deterministic title/author detection (metadata, first-page text, OCR of scanned first pages, file name), sources recorded in book.json; decrypt scratch copy before OCR
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user