from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import letter from reportlab.lib.colors import HexColor from reportlab.lib.units import inch OUT_PATH = r"C:\Users\jhodgkin\Pictures\Dearest Mother I Love You.pdf" LINES = [ "Gentle words I hear you say.", "Your kind hands help me each day.", "You’re my mother kind and true;", "Dearest mother, I love you.", ] TITLE = "Dearest Mother, I Love You" W, H = letter # 8.5 x 11 inches PINK = HexColor("#F48FB1") SOFT_PINK = HexColor("#FCE4EC") DEEP_ROSE = HexColor("#C2185B") GOLD = HexColor("#F9A825") def draw_flower(c, cx, cy, r=18, petals=6, petal_color=None, center_color=None): import math petal_color = petal_color or PINK center_color = center_color or GOLD for i in range(petals): angle = math.radians(i * 360 / petals) px = cx + math.cos(angle) * r * 1.1 py = cy + math.sin(angle) * r * 1.1 c.setFillColor(petal_color) c.circle(px, py, r * 0.65, fill=1, stroke=0) c.setFillColor(center_color) c.circle(cx, cy, r * 0.45, fill=1, stroke=0) def make_pdf(): c = canvas.Canvas(OUT_PATH, pagesize=letter) # Corner flowers corners = [ (0.65*inch, 0.65*inch), (W - 0.65*inch, 0.65*inch), (0.65*inch, H - 0.65*inch), (W - 0.65*inch, H - 0.65*inch), ] for cx, cy in corners: draw_flower(c, cx, cy) # Title c.setFillColor(DEEP_ROSE) c.setFont("Helvetica-BoldOblique", 28) c.drawCentredString(W / 2, H - 1.5*inch, TITLE) # Divider line under title c.setStrokeColor(PINK) c.setLineWidth(2) c.line(1.2*inch, H - 1.75*inch, W - 1.2*inch, H - 1.75*inch) # Lyrics — evenly spaced c.setFillColor(HexColor("#4A148C")) c.setFont("Helvetica-Bold", 26) top = H - 2.4*inch spacing = 1.0*inch for i, line in enumerate(LINES): y = top - i * spacing c.drawCentredString(W / 2, y, line) # Small decorative flowers between lines for i in range(len(LINES) - 1): y = top - i * spacing - spacing / 2 draw_flower(c, W / 2, y, r=8) # Footer c.setFillColor(DEEP_ROSE) c.setFont("Helvetica-Oblique", 14) c.drawCentredString(W / 2, 0.75*inch, "Happy Mother’s Day") c.save() print(f"Saved: {OUT_PATH}") make_pdf()