Example #1
0
def __to_pdf(tempFile, breakdown, building, begin_ts, end_ts):
    doc = SimpleDocTemplate(tempFile, pagesize=landscape(A4), leftMargin=MARGIN,
                            rightMargin=MARGIN, topMargin=MARGIN,
                            bottomMargin=MARGIN,
                            title=u'Lista de întreținere %s' % building.name,
                            author='www.habitam.ro')
    flowables = []
    sc_title_style = ParagraphStyle(name='staircase_title', alignment=TA_CENTER)
                         
    for sc in building.apartment_groups():
        if sc == building:
            continue
        sc_title = Paragraph(u'Lista de întreținere scara %s' % 
                             sc.name, sc_title_style)
        data = __list_data(sc, breakdown, building.services())
    
        table = Table(data, repeatRows=1)
        table.setStyle(TableStyle([
                        ('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
                        ('VALIGN', (0, 0), (0, -1), 'TOP'),
                        ('FONTSIZE', (0, 0), (-1, -1), __FONT_SIZE__),
                        ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black)
                       ]))

        flowables.extend([Spacer(1, .5 * cm), sc_title,
                          Spacer(1, cm), table,
                          Spacer(1, .5 * cm), signatures(__FONT_SIZE__),
                          PageBreak()])
    
    doc.habitam_building = building
    doc.habitam_month = begin_ts.strftime('%B %Y')
    doc.habitam_display = date.today().strftime('%d %B %Y')
    doc.build(flowables, onFirstPage=__list_format, onLaterPages=__list_format)
Example #2
0
def __to_pdf(tempFile, data, building, title):
    
   
    doc = SimpleDocTemplate(tempFile, pagesize=A4, leftMargin=MARGIN,
                            rightMargin=MARGIN, topMargin=MARGIN,
                            bottomMargin=MARGIN,
                            title=title,
                            author='www.habitam.ro')    
    
    register_title_style = ParagraphStyle(name='register_title', alignment=TA_CENTER)
    register_title = Paragraph(title, register_title_style)
    
    table = Table(data, colWidths=[1.3 * cm, 3 * cm, 1.2 * cm, 7.5 * cm, 2 * cm, 2 * cm, 1.7 * cm])
    table.setStyle(TableStyle([
                        ('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
                        ('FONTSIZE', (0, 0), (-1, -1), __FONT_SIZE__),
                        ('ALIGN', (0, 0), (-1, 0), 'CENTER'),
                        ('ALIGN', (0, 0), (0, -1), 'CENTER'),
                        ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
                        ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black)
                        ]))

    flowables = [Spacer(1, 1.5 * cm), register_title, Spacer(1, cm), table]
    
    doc.habitam_building = building  
    doc.build(flowables, onFirstPage=__register_format, onLaterPages=__register_format)