DEV Community

ER Carltz
ER Carltz

Posted on

Generating 300 DPI Print-Ready Wall Calendars in Python (Zero InDesign Required)

This is Part 4 of the zero-bloat engineering series behind SOL-2027 — an interactive web explorer and print suite reviving Eastman Kodak’s 1928–1989 13-month International Fixed Calendar (13 × 28 + Year Day) for 2027:

Once the browser explorer and 1080×1920 story cards were live, readers asked for physical wall posters, writable desk packs, and hanging spiral calendars. That meant outputting 18×24", 36×24", 24×18", A4, A3-compatible ISO sheets, US Letter, and a 38-page Lulu Wire-O wall calendar (2027 + early 2028) across multiple palettes and weekday modes.

Doing that manually in InDesign or Canva is brittle: update one solstice marker or swap perpetual SUN–SAT columns for real-world 2027 FRI–THU weekdays, and you're re-editing 365 cells across a dozen templates. So we automated the entire pre-press pipeline in Python using ReportLab, PyMuPDF (pymupdf), PyEphem (ephem), and Pillow.


1. Print Geometry, Bleed & Safe-Zone Math

Print specifications start with PostScript points (72 pt = 1 inch). Defining dimensions in code keeps every poster, writable sheet, and print-on-demand (POD) bleed box mathematically locked:

  • 18×24" Swiss Posters (build_style1_swiss.py): W, H = 1296.0, 1728.0 points, rasterized at dpi=300 into 5400 × 7200 px PNGs.
  • 36×24" Giant Linear Wall Planner (build_style2_linear.py): W, H = 2592.0, 1728.0 points (10800 × 7200 px at 300 DPI, exported at dpi=200 / 7200 × 4800 px for POD upload caps).
  • 38-Page Lulu Wire-O Edition (build_lulu_18month_suite.py): An 11.0" × 8.5" closed landscape spread plus 0.125" (9.0 pt) full bleed on all four edges (11.25" × 8.75"), giving W = 810.0, H = 630.0, BLEED = 9.0, and 45 pt Wire-O coil and hang-hole clearances (SAFE_MIN_Y = 48.0, SAFE_MAX_Y = 582.0).
# build_lulu_18month_suite.py — Lulu 11.0" x 8.5" + 0.125" (9 pt) full bleed
W, H, BLEED = 810.0, 630.0, 9.0
SAFE_MIN_Y, SAFE_MAX_Y = 48.0, 582.0  # Keep clear of Wire-O coil & hang hole
ML, MR = 45.0, 45.0
GW = W - ML - MR  # 720.0 pt live grid width

# build_style1_swiss.py — Dual Swiss themes with Open Font License typography
THEMES = {
    "archival": {
        "bg": HexColor("#F4F0E8"), "ink": HexColor("#141414"),
        "accent": HexColor("#D94420"), "sol_bg": HexColor("#F7EAE3"),
    },
    "noir": {
        "bg": HexColor("#131416"), "ink": HexColor("#F3EFE8"),
        "accent": HexColor("#EB5530"), "sol_bg": HexColor("#261916"),
    },
}
Enter fullscreen mode Exit fullscreen mode

We embed OFL fonts (Inter and SpaceMono) upfront via pdfmetrics.registerFont(TTFont(...)) and wrap drawString in draw_tracked() for Stendig-scale negative tracking (tracking=-4.5 on 2027 at 142 pt).


2. Swiss 13×28 Grid Math & Dual Gregorian Badges

ReportLab draws bottom-up in points, making modular Swiss layouts pure coordinate arithmetic. On the 18×24" poster (build_swiss_poster()), an M = 84.0 margin and GUTTER_X = 36.0 split the 1128 pt width into three 352 pt columns (COL_W = (GW - 2 * GUTTER_X) / 3.0), forming a 5×3 grid: 13 months + Slot 14 (Year Day · Dec 29) + Slot 15 (System Specification).

For writable monthly spreads (build_swiss_monthly_14p(), draw_monthly_grid_page()), each box pairs the IFC day (1–28) with its Gregorian cross-date (ifc_to_greg()), flips Gregorian 1sts (gd.day == 1) into a solid #141414 or #162238 micro-pill, and overlays ephem solstice/lunar markers:

for day in range(1, 29):
    r, ci = (day - 1) // 7, (day - 1) % 7
    bx, by = M + ci * cw, grid_top - (r + 1) * ch

    c.setFillColor(th["wknd_bg"] if ci in wknd_cols else th["cell_bg"])
    c.setStrokeColor(th["hairline"])
    c.rect(bx, by, cw, ch, fill=1, stroke=1)

    c.setFont("Inter-Bold", 17.5)
    c.setFillColor(th["accent"] if (ci in wknd_cols or is_sol) else th["ink"])
    c.drawString(bx + 7, by + ch - 21, str(day))

    gd = ifc_to_greg(m_idx, day)
    g_str = gd.strftime("%b %-d").upper()
    if gd.day == 1:  # High-contrast pill on Gregorian 1sts
        c.setFillColor(th["ink"])
        c.rect(bx + cw - 43.0, by + ch - 18.5, 38.0, 12.5, fill=1, stroke=0)
        c.setFillColor(HexColor("#FFFFFF"))
        c.setFont("SpaceMono-Bold", 6.8)
        c.drawCentredString(bx + cw - 24.0, by + ch - 15.0, g_str)
    else:
        c.setFont("SpaceMono-Regular", 7.0)
        c.setFillColor(th["ink_muted"])
        c.drawRightString(bx + cw - 6, by + ch - 15.5, g_str)
Enter fullscreen mode Exit fullscreen mode

3. Multi-Size Scaling, Wrap Imposition & Automated QA

Once the master vector PDF exists, PyMuPDF (pymupdf) handles scaling, cover imposition, pre-press checks, and high-DPI PNG export, while Pillow (PIL.Image) downsamples oversampled PDF renders via Image.Resampling.LANCZOS for photorealistic wall proofing (build_wall_demos.py):

def export_scaled(src_pdf, dst_pdf, pw, ph, bg_rgb, title):
    src, out = pymupdf.open(src_pdf), pymupdf.open()
    pg = out.new_page(width=pw, height=ph)
    pg.draw_rect(pg.rect, color=None, fill=bg_rgb)
    sw, sh = src[0].rect.width, src[0].rect.height
    sc = min(pw / sw, ph / sh)
    dw, dh = sw * sc, sh * sc
    x0, y0 = (pw - dw) / 2.0, (ph - dh) / 2.0
    pg.show_pdf_page(pymupdf.Rect(x0, y0, x0 + dw, y0 + dh), src, 0)
    out.set_metadata({"title": title})
    out.save(dst_pdf, garbage=4, deflate=True)

# 18x24" vector PDF -> 5400 x 7200 px 300 DPI PNG + 4961 x 7016 ISO (A4/A3) PNG
pymupdf.open(pdf_18x24)[0].get_pixmap(dpi=300, alpha=False).save(png_18x24)
pymupdf.open(pdf_a4)[0].get_pixmap(dpi=600, alpha=False).save(png_rb)
Enter fullscreen mode Exit fullscreen mode

Because A4 (595.28 × 841.89 pt) and A3 share the exact 1:1.414 (1:√2) ISO aspect ratio, export_scaled() scales cleanly from US Letter (612.0 × 792.0 pt) up through A3 and giant wall sheets.

For the 38-page Lulu suite, derive_split_and_wrap_pdfs() splits the master PDF into the 36pp interior, 2pp cover, and a 1602 × 630 pt (22.25" × 8.75") wrap spread by clipping inner 9 pt spine bleed (clip=pymupdf.Rect(0, 0, 801, 630) and Rect(9, 0, 810, 630)). Finally, verify_suite() scans every page.get_text("dict")["blocks"] and page.get_drawings() bounding box to reject any path touching the 45 pt Wire-O zone, then renders 150–300 DPI proofing PNGs.


Explore the Code Output & 2027 Editions

Every PDF, PNG, and shipped wall edition produced by these scripts is live across the SOL-2027 site:

If you've replaced Adobe InDesign or Canva templates with ReportLab, WeasyPrint, or Typst for multi-format print automation, what pre-press edge cases tripped you up?

Top comments (0)