Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from reportlab.lib.pagesizes import (ELEVENSEVENTEEN,
- landscape)
- from reportlab.pdfgen import canvas
- from reportlab.lib.units import inch
- from reportlab.lib.utils import ImageReader
- DWGSize = landscape(ELEVENSEVENTEEN)
- dwg = canvas.Canvas(filename='TestDWG.pdf',
- pagesize=DWGSize)
- width, height = DWGSize # for ref later
- Margin = 0.3125*inch
- DblMargin = Margin*2
- dwg.rect(x=Margin, # Title block outside border
- y=Margin,
- width=width-DblMargin,
- height=height-DblMargin,
- fill=0)
- dwg.line(x1=Margin, # line below logo in title block
- y1=3.875*inch,
- x2=1.5*inch,
- y2=3.875*inch)
- dwg.line(x1=Margin, # line above logo in title block
- y1=6.875*inch,
- x2=1.5*inch,
- y2=6.875*inch)
- dwg.line(x1=1.5*inch, # line seperating title block from rest of drawing
- y1=Margin,
- x2=1.5*inch,
- y2=height-Margin)
- LOGO_PATH = 'C:/Users/libbyl/PythonProjects/DrawingWithReportLab/Bergkamp register R logo RGB black.jpeg'
- BlkLogo = ImageReader(LOGO_PATH)
- dwg.rotate(90)
- dwg.drawImage(BlkLogo, # put logo in middle box of title block
- x=0.3125*inch,
- y=3.875*inch,
- mask='auto')
- dwg.showPage()
- dwg.save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement