From Idea to Editable PDF: A 60-Line Habit-Tracker Generator
Python script to generate Editable Habit Tracker/Form
Kashif Nadeem
9/27/20252 min read
Most productivity printables on Pinterest are static: you download, print, and—if your goals change—re-print.
What if you could e-mail a single PDF that works for any month, lets the recipient type in their own habits, and still gives them the tactile joy of ticking boxes?
Below is a tiny Python script that does exactly that.
In less than a minute it spits out a landscape A4 file with:
a centered, editable “Month” field
ten blank habit rows (type anything)
30 check-boxes per habit (one full month)
a discreet branding footer so people remember who helped them stay consistent
No Adobe licence, no Canva Pro, no manual copy-paste. Just pure ReportLab magic.
Live Code Walk-through
The whole generator is 60 lines, comments included.
Copy it into a Jupyter cell, a .py file, or even Google Colab and run.
Python
Copy
from reportlab.lib.pagesizes import A4, landscape from reportlab.pdfgen import canvas from reportlab.lib.units import cm from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.cidfonts import UnicodeCIDFont # ------------------------------------------------- # 1. Register a Japanese font so we can use UTF-8 # (swap for any TTF you like) # ------------------------------------------------- pdfmetrics.registerFont(UnicodeCIDFont('HeiseiMin-W3')) def create_landscape_editable_pdf_with_header(filename): from reportlab.pdfbase import pdfform c = canvas.Canvas(filename, pagesize=landscape(A4)) width, height = landscape(A4) # ------------------------------------------------- # 2. Editable Month field (centered) # ------------------------------------------------- field_width = 8*cm field_height = 0.8*cm month_x = (width - field_width) / 2 month_y = height - 1.5*cm c.setFont("HeiseiMin-W3", 12) c.drawCentredString(width/2, height - 1*cm, "Month:") c.acroForm.textfield(name="month_name", x=month_x, y=month_y-0.3*cm, width=field_width, height=field_height, borderStyle='underlined', forceBorder=True) # ------------------------------------------------- # 3. Header row: day numbers 1-30 # ------------------------------------------------- left_margin = 2*cm row_height = 1.2*cm col_width = 0.7*cm start_y = height - 3*cm c.setFont("HeiseiMin-W3", 8) for d in range(30): x = left_margin + 4.5*cm + d*col_width c.drawCentredString(x+col_width/2, start_y + 0.6*cm, str(d+1)) # ------------------------------------------------- # 4. Ten habit rows: editable label + 30 checkboxes # ------------------------------------------------- c.setFont("HeiseiMin-W3", 9) for i in range(10): y = start_y - i*row_height # habit name c.acroForm.textfield(name=f"habit{i+1}", x=left_margin, y=y-0.3*cm, width=3.5*cm, height=0.8*cm, borderStyle='underlined', forceBorder=True) # daily boxes for d in range(30): x = left_margin + 4.5*cm + d*col_width c.acroForm.checkbox(name=f"h{i+1}_d{d+1}", x=x, y=y-0.1*cm, buttonStyle='check', size=10) # ------------------------------------------------- # 5. Subtle branding footer # ------------------------------------------------- c.setFont("HeiseiMin-W3", 9) c.drawCentredString(width/2, 1*cm, "Created by Code2Compass ✦ www.code2compass.com") c.showPage() c.save() # ------------------------------------------------- # 6. Generate the file # ------------------------------------------------- create_landscape_editable_pdf_with_header("HabitTracker-Landscape-Editable-Header.pdf")
How to Use the PDF
Run the script (only dependency is reportlab: pip install reportlab).
Open the generated PDF in Adobe Acrobat Reader (free) or Foxit.
Click the “Month” field, type “July 2025”, hit Enter.
Type ten habits—e.g. “Read 10 pages”, “10 push-ups”, “No soda”.
Tick boxes as you go; save the file.
At month-end, reset the ticks and reuse the same template.
Tweaks You’ll Love
Table
Copy
WishOne-line fix31-day monthsChange range(30) to range(31)Portrait orientationReplace landscape(A4) with A4Your own fontSwap UnicodeCIDFont('HeiseiMin-W3') for pdfmetrics.registerFont(TTFont('MyFont','MyFont.ttf'))More habitsReplace range(10) with any numberCustom brandingEdit the footer string
Why Not Just Use Excel?
Excel is editable, but:
PDF locks the layout—your columns will never mis-align on someone else’s screen.
Checkboxes feel faster than typing “x”.
A single file feels like a gift; an .xlsx feels like homework.
Ship It
Host the PDF behind a newsletter sign-up, offer it as a freebie on Twitter, or print-and-staple 50 copies for your next workshop.
The code is MIT-licensed: attribution appreciated, commercial use totally fine.
Stay consistent, stay coding.