You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4.4 KiB
4.4 KiB
ReportLab A0 Canvas¶
Using loops and variables to create an A0 grid...
https://www.reportlab.com/docs/reportlab-userguide.pdf#page=10
In [37]:
from reportlab.pdfgen.canvas import Canvas from reportlab.lib.pagesizes import A4, A0 from reportlab.lib.units import inch, cm, mm import sys from reportlab.pdfbase.ttfonts import TTFont, pdfmetrics
In [38]:
c = Canvas("grid.pdf", pagesize=A0)
In [39]:
c.line?
Signature: c.line(x1, y1, x2, y2) Docstring: draw a line segment from (x1,y1) to (x2,y2) (with color, thickness and other attributes determined by the current graphics state). File: /usr/local/lib/python3.7/dist-packages/reportlab/pdfgen/canvas.py Type: method
In [40]:
c.setLineWidth?
Signature: c.setLineWidth(width) Docstring: <no docstring> File: /usr/local/lib/python3.7/dist-packages/reportlab/pdfgen/canvas.py Type: method
In [41]:
c.line(0, 0, 100, 200)
In [42]:
c.setLineWidth(3*mm)
In [43]:
c.line(0, 0, 200, 100)
In [44]:
pagew, pageh = A0 colw = pagew/4 print (A0) print (colw)
(2383.937007874016, 3370.393700787402) 595.984251968504
In [45]:
for x in range(4): c.line(x*colw, 0, x*colw, pageh)
In [46]:
colh = pageh/4 print (colh) for y in range(4): c.line(0, y*colh, pagew, y*colh)
842.5984251968505
In [47]:
c.showPage() c.save()