'''Generate BlackBerry PlayBook screen templates.
        Copyright 2010 Peter Hansen.  http://peterhansen.ca
        Free for any use.
    '''
    
    from reportlab.lib.pagesizes import LETTER
    from reportlab.pdfgen import canvas
    
    def mm(x):
        from reportlab.lib.units import mm
        return x * mm
    
    destination_file = 'pbscreen_3.pdf'
    
    height = mm(90.0)
    width = mm(153.6)
    weight = mm(0.0)
    padding = mm(0.2)
    margin = mm(10.0)
    
    def main():
        c = canvas.Canvas(destination_file, pagesize=LETTER)
    
        c.setLineWidth(weight)
        for left, bottom, orientation in [
            (0, 0, 'rotated'),
            (height + padding + weight, 0, 'rotated'),
            (0, width + padding + weight, 'normal'),
            ]:
            w, h = (width, height) if orientation == 'normal' else (height, width)
            c.rect(margin + left, margin + bottom, w, h)
    
        c.setFont('Helvetica', 9)
        c.drawString(mm(20), mm(268), 'BlackBerry PlayBook screen template, v1')
        c.drawString(mm(20), mm(263), 'Courtesy of Peter Hansen.  Free for any use.')
    
        c.setFont('Courier', 9)
        c.drawString(mm(30), mm(258), 'http://peterhansen.ca')
    
        c.showPage()
        c.save()
    
    
    if __name__ == '__main__':
        main()