Create a clean, elegant, professional A5 portrait medical prescription pad suitable for printing. Header: Dr Gowri Krishna S H MBBS Reg. No.: 100332 Contact: 7902739910 Keep the doctor’s name moderately sized, not overly bold. Place MBBS neatly below the name and the registration number/contact in smaller text. Add Date: __________ at the top-right. Patient details: Patient Name: ______________________________ Age: __________ Sex: __________ Arrange these neatly in one horizontal row. Clinical section: Below patient details, create a C/O: with adequate writing space. Below this, create a large Rx prescription area with plenty of blank space for handwritten prescriptions. Right-side section: Create a narrow vertical column on the right, separated by a thin divider, containing: Past History: with adequate blank space Vitals: with separate space for recording vitals Bottom section: Divide the bottom into two sections: INVESTIGATION TO DO: moderate writing space REVIEW: moderate writing space Design: minimalist, professional medical aesthetic; white/off-white background; thin navy-blue/grey borders and divider lines; clean typography; generous handwriting space; no unnecessary decorations, hospital/clinic name, address, or signature box. Ensure every text element is spelled exactly as specified and the overall layout looks realistic and printable.
mkdir -p /tmp/workspace/prescription-pad && ls /tmp/workspace/prescription-pad/
~/prescription-pad/generate_rx.py
from reportlab.lib.pagesizes import A5
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
from reportlab.lib.colors import HexColor, white
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
# ── page setup ────────────────────────────────────────────────────────────────
PAGE_W, PAGE_H = A5 # 148 x 210 mm (419.53 x 595.28 pt)
MARGIN = 12 * mm
NAV = HexColor("#1A3A5C") # navy-blue for accents / lines
GREY_LIGHT = HexColor("#E8ECF0") # subtle rule colour
TEXT_DARK = HexColor("#1C1C1C")
TEXT_MID = HexColor("#3A3A3A")
TEXT_LIGHT = HexColor("#666666")
BG = HexColor("#FAFAFA") # off-white
def line(c, x1, y1, x2, y2, color=NAV, width=0.6):
c.setStrokeColor(color)
c.setLineWidth(width)
c.line(x1, y1, x2, y2)
def label(c, text, x, y, size=7, color=TEXT_LIGHT, font="Helvetica"):
c.setFont(font, size)
c.setFillColor(color)
c.drawString(x, y, text)
def underline_field(c, x, y, width, thin=True):
lw = 0.4 if thin else 0.5
line(c, x, y, x + width, y, color=GREY_LIGHT, width=lw)
# ── build PDF ─────────────────────────────────────────────────────────────────
out = "/tmp/workspace/prescription-pad/prescription_pad.pdf"
c = canvas.Canvas(out, pagesize=A5)
c.setTitle("Medical Prescription Pad – Dr Gowri Krishna S H")
W, H = PAGE_W, PAGE_H
# background
c.setFillColor(BG)
c.rect(0, 0, W, H, stroke=0, fill=1)
# outer border (thin navy)
c.setStrokeColor(NAV)
c.setLineWidth(0.8)
c.rect(MARGIN, MARGIN, W - 2*MARGIN, H - 2*MARGIN, stroke=1, fill=0)
# ── HEADER ────────────────────────────────────────────────────────────────────
header_top = H - MARGIN # top of inner box
header_bottom = H - MARGIN - 22*mm
left = MARGIN
right = W - MARGIN
inner_w = right - left
# thin accent bar under header
line(c, left, header_bottom, right, header_bottom, color=NAV, width=0.8)
# doctor name – moderate weight, not oversized
c.setFont("Helvetica-Bold", 13.5)
c.setFillColor(NAV)
c.drawString(left + 4*mm, header_top - 8*mm, "Dr Gowri Krishna S H")
# MBBS
c.setFont("Helvetica", 8)
c.setFillColor(TEXT_MID)
c.drawString(left + 4*mm, header_top - 13.5*mm, "MBBS")
# Reg. No. and Contact
c.setFont("Helvetica", 7)
c.setFillColor(TEXT_LIGHT)
c.drawString(left + 4*mm, header_top - 17.5*mm, "Reg. No.: 100332 Contact: 7902739910")
# Date field – top right
c.setFont("Helvetica", 7.5)
c.setFillColor(TEXT_DARK)
date_label_x = right - 36*mm
date_label_y = header_top - 8*mm
c.drawString(date_label_x, date_label_y, "Date:")
# underline for date
underline_field(c, date_label_x + 9*mm, date_label_y - 0.5*mm, 26*mm, thin=False)
# ── PATIENT DETAILS ROW ───────────────────────────────────────────────────────
pt_y_top = header_bottom - 3*mm
pt_y_line = pt_y_top - 5.5*mm # underline y
# Patient Name
c.setFont("Helvetica", 7.5)
c.setFillColor(TEXT_DARK)
c.drawString(left + 4*mm, pt_y_top, "Patient Name:")
name_line_x = left + 4*mm + 22*mm
name_line_w = 52*mm
underline_field(c, name_line_x, pt_y_line, name_line_w)
# Age
age_x = left + 4*mm + 22*mm + 54*mm
c.drawString(age_x, pt_y_top, "Age:")
underline_field(c, age_x + 8*mm, pt_y_line, 14*mm)
# Sex
sex_x = age_x + 8*mm + 15*mm + 4*mm
c.drawString(sex_x, pt_y_top, "Sex:")
underline_field(c, sex_x + 8*mm, pt_y_line, 12*mm)
# thin separator below patient row
sep1_y = pt_y_line - 4*mm
line(c, left, sep1_y, right, sep1_y, color=GREY_LIGHT, width=0.5)
# ── RIGHT COLUMN DIVIDER ──────────────────────────────────────────────────────
# Right column starts at 68% of inner width
right_col_x = left + inner_w * 0.68
line(c, right_col_x, sep1_y, right_col_x, MARGIN + 20*mm, color=NAV, width=0.5)
# ── C/O SECTION ───────────────────────────────────────────────────────────────
co_top = sep1_y - 2*mm
c.setFont("Helvetica-Bold", 8)
c.setFillColor(TEXT_DARK)
c.drawString(left + 4*mm, co_top, "C/O:")
co_lines_x = left + 14*mm
co_line_spacing = 5.5*mm
co_num_lines = 3
for i in range(co_num_lines):
ly = co_top - 5*mm - i * co_line_spacing
underline_field(c, co_lines_x, ly, right_col_x - co_lines_x - 4*mm)
sep2_y = co_top - 5*mm - (co_num_lines - 1) * co_line_spacing - 5*mm
line(c, left, sep2_y, right_col_x, sep2_y, color=GREY_LIGHT, width=0.5)
# ── Rx SECTION ───────────────────────────────────────────────────────────────
rx_top = sep2_y - 2.5*mm
# Big Rx symbol
c.setFont("Helvetica-BoldOblique", 18)
c.setFillColor(NAV)
c.drawString(left + 4*mm, rx_top, "Rx")
# subtle horizontal lines for writing
rx_line_area_top = rx_top - 6*mm
rx_bottom = MARGIN + 20*mm # align with bottom of right col
rx_line_spacing = 6.5*mm
rx_y = rx_line_area_top
while rx_y - rx_line_spacing > rx_bottom:
rx_y -= rx_line_spacing
underline_field(c, left + 4*mm, rx_y, right_col_x - left - 8*mm)
# ── RIGHT COLUMN CONTENT ──────────────────────────────────────────────────────
rc_left = right_col_x + 3*mm
rc_right = right - 3*mm
rc_w = rc_right - rc_left
rc_top = sep1_y - 2.5*mm
# Past History
c.setFont("Helvetica-Bold", 7.5)
c.setFillColor(TEXT_DARK)
c.drawString(rc_left, rc_top, "Past History:")
ph_lines = 5
for i in range(ph_lines):
ly = rc_top - 6*mm - i * 5.5*mm
underline_field(c, rc_left, ly, rc_w)
# Vitals header
vitals_top = rc_top - 6*mm - ph_lines * 5.5*mm - 5*mm
line(c, right_col_x, vitals_top + 3*mm, right, vitals_top + 3*mm, color=GREY_LIGHT, width=0.4)
c.setFont("Helvetica-Bold", 7.5)
c.setFillColor(TEXT_DARK)
c.drawString(rc_left, vitals_top, "Vitals:")
vital_items = ["BP:", "Pulse:", "Temp:", "SpO₂:", "Wt:"]
for i, v in enumerate(vital_items):
vy = vitals_top - 5.5*mm - i * 6*mm
c.setFont("Helvetica", 6.5)
c.setFillColor(TEXT_MID)
c.drawString(rc_left, vy, v)
underline_field(c, rc_left + 8*mm, vy - 0.5*mm, rc_w - 8*mm)
# ── BOTTOM SECTION ────────────────────────────────────────────────────────────
bottom_sep_y = MARGIN + 20*mm
line(c, left, bottom_sep_y, right, bottom_sep_y, color=NAV, width=0.6)
# vertical divider splitting bottom in half
bottom_mid_x = left + inner_w * 0.5
line(c, bottom_mid_x, bottom_sep_y, bottom_mid_x, MARGIN, color=GREY_LIGHT, width=0.5)
bottom_label_y = bottom_sep_y - 4*mm
bottom_line_y = bottom_label_y - 5*mm
inv_line_w = bottom_mid_x - left - 8*mm
rev_line_w = right - bottom_mid_x - 8*mm
# Investigation
c.setFont("Helvetica-Bold", 7.5)
c.setFillColor(TEXT_DARK)
c.drawString(left + 4*mm, bottom_label_y, "INVESTIGATION TO DO:")
for i in range(2):
underline_field(c, left + 4*mm, bottom_line_y - i * 5.5*mm, inv_line_w)
# Review
c.drawString(bottom_mid_x + 4*mm, bottom_label_y, "REVIEW:")
for i in range(2):
underline_field(c, bottom_mid_x + 4*mm, bottom_line_y - i * 5.5*mm, rev_line_w)
# ── SAVE ─────────────────────────────────────────────────────────────────────
c.save()
print(f"Saved: {out}")
cd /tmp/workspace/prescription-pad && python generate_rx.py
cd /tmp/workspace/prescription-pad && python -c " import subprocess, sys # Convert first page to PNG for preview result = subprocess.run( ['python3', '-c', ''' import fitz # pymupdf doc = fitz.open(\"/tmp/workspace/prescription-pad/prescription_pad.pdf\") page = doc[0] mat = fitz.Matrix(3, 3) # 3x zoom = ~216 dpi pix = page.get_pixmap(matrix=mat, alpha=False) pix.save(\"/tmp/workspace/prescription-pad/preview.png\") print(\"Preview saved\") '''], capture_output=True, text=True ) print(result.stdout) print(result.stderr) "
pip install --user pymupdf -q && python3 -c "import fitz; print('pymupdf ok', fitz.__version__)"
python3 -c " import fitz doc = fitz.open('/tmp/workspace/prescription-pad/prescription_pad.pdf') page = doc[0] mat = fitz.Matrix(3, 3) pix = page.get_pixmap(matrix=mat, alpha=False) pix.save('/tmp/workspace/prescription-pad/preview.png') print('Preview saved, size:', pix.width, 'x', pix.height) "
python3 -c " import fitz doc = fitz.open('/tmp/workspace/prescription-pad/prescription_pad.pdf') page = doc[0] text = page.get_text('words') # Print all words with positions for w in text: print(f' ({w[0]:.1f},{w[1]:.1f}) -> \"{w[4]}\"') "
~/prescription-pad/generate_rx.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/prescription-pad/generate_rx.py'
cd /tmp/workspace/prescription-pad && python generate_rx.py
prescription pad
PDF Document · PDF
| Zone | Content |
|---|---|
| Header | "Dr Gowri Krishna S H" in moderate navy-blue bold (13.5pt) - MBBS below in regular weight - Reg. No. + Contact in small light text - "Date: ___" field top-right |
| Patient Row | Patient Name / Age / Sex in one horizontal line with underline fields |
| C/O section | Label + 3 writing lines |
| Rx area | Large italic Rx symbol (navy) + generous ruled writing space taking up most of the left column |
| Right column | Thin navy vertical divider at 68% width - "Past History" with 5 writing lines - "Vitals" with BP / Pulse / Temp / SpO2 / Wt fields |
| Bottom strip | Navy horizontal rule dividing the bottom bar - left half: INVESTIGATION TO DO - right half: REVIEW - both with writing lines |