from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import A4 from reportlab.lib.units import mm width, height = (181.7 * mm, 256.8 * mm) numv = int((width - ((17 + 4) * mm)) / (5 * mm)) numh = int((height / 2.0 - (5 + 5) * mm) / (5 * mm)) voff = 17 * mm hoff = (height / 2 - numh * 5 * mm) / 2.0 c = canvas.Canvas("b6.pdf", pagesize=(width, height)) # Draw grid c.setLineWidth(0.15) c.setStrokeColorRGB(0.5, 0.5, 1) for xi in xrange(numv + 1): c.line(xi * mm * 5 + voff, hoff, xi * mm * 5 + voff, hoff + numh * mm * 5) c.line(xi * mm * 5 + voff, height - hoff, xi * mm * 5 + voff, height - (hoff + numh * mm * 5)) for yi in xrange(numh + 1): c.line(voff, hoff + yi * mm * 5, voff + numv * mm * 5, hoff + yi * mm * 5) c.line(voff, height - (hoff + yi * mm * 5), voff + numv * mm * 5, height - (hoff + yi * mm * 5)) # Draw horizontal center c.setDash(1) c.setStrokeColorRGB(0.5, 0.5, 1) c.circle(5 * mm, height / 4, 0.5, fill=1) c.circle(5 * mm, height / 4 * 3, 0.5, fill=1) # Draw splitter line c.setDash([3, 3]) c.setStrokeColorRGB(0.4, 0.4, 0.4) c.line(0, height / 2, width, height / 2) c.save()