craiyon logo

Close-up photograph of a computer monitor displaying Python code on a dark theme, next to a desk lamp and a notebook.

Close-up photograph of a computer monitor displaying Python code on a dark theme, next to a desk lamp and a notebook.

from reportlab.lib.pagesizes import A5 from reportlab.pdfgen import canvas from reportlab.lib import colors from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.cidfonts import UnicodeCIDFont from reportlab.lib.units import mm import math, os, textwrap out="/mnt/data/Japan_Travel_Journal_Scrapbook_A5.pdf" W,H=A5 paper=colors.HexColor("#F7F0E7") cream=colors.HexColor("#FBF7F0") paper2=colors.HexColor("#F2E8DC") ink=colors.HexColor("#514B47") red=colors.HexColor("#B85C5C") dusty=colors.HexColor("#D98B91") blue=colors.HexColor("#A9C7D2") green=colors.HexColor("#7D9A7C") brown=colors.HexColor("#8C6B55") yellow=colors.HexColor("#E7C982") grey=colors.HexColor("#CFC5BB") white=colors.white pdfmetrics.registerFont(UnicodeCIDFont("HeiseiKakuGo-W5")) jp="HeiseiKakuGo-W5" c=canvas.Canvas(out,pagesize=A5) def bg(col=paper): c.setFillColor(col); c.rect(0,0,W,H,fill=1,stroke=0) def t(x,y,s,size=7,col=ink,font=jp): c.setFillColor(col); c.setFont(font,size); c.drawString(x,y,s) def tc(x,y,s,size=7,col=ink,font=jp): c.setFillColor(col); c.setFont(font,size); c.drawCentredString(x,y,s) def rot_text(x,y,s,size,angle,col=ink): c.saveState(); c.translate(x,y); c.rotate(angle) t(0,0,s,size,col); c.restoreState() def roundbox(x,y,w,h,fill=cream,stroke=grey,r=3,lw=.6): c.setFillColor(fill); c.setStrokeColor(stroke); c.setLineWidth(lw) c.roundRect(x,y,w,h,r*mm,fill=1,stroke=1) def tape(x,y,w,h,col=yellow,angle=-4): c.saveState(); c.translate(x,y); c.rotate(angle) c.setFillColor(col); Ver mais