Changeset 6364 for main


Ignore:
Timestamp:
14 Jun 2011, 07:48:01 (14 years ago)
Author:
Henrik Bettermann
Message:

Finetune application slip.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r6363 r6364  
    3333from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    3434from reportlab.pdfgen import canvas
     35from reportlab.lib.units import cm
     36from reportlab.lib.pagesizes import A4, landscape
     37from reportlab.lib.styles import getSampleStyleSheet
     38from reportlab.platypus import (Frame, Paragraph, Image,
     39    Table, Spacer)
     40from reportlab.platypus.flowables import HRFlowable
     41from reportlab.platypus.tables import TableStyle
    3542
    3643from waeup.sirp.accesscodes import invalidate_accesscode
     
    568575
    569576    def render(self):
    570         from reportlab.pdfgen import canvas
    571         from reportlab.lib.units import cm
    572         from reportlab.lib.pagesizes import A4, landscape
    573         from reportlab.lib.styles import getSampleStyleSheet
    574         from reportlab.platypus import (Frame, Paragraph, Image,
    575             Table, Spacer)
    576         from reportlab.platypus.flowables import HRFlowable
     577        # (0,0),(-1,-1) = whole table
     578        # (0,0),(0,-1) = first column
     579        # (-1,0),(-1,-1) = last column
     580        # (0,0),(-1,0) = first row
     581        # (0,-1),(-1,-1) = last row
     582        SLIP_STYLE = TableStyle(
     583            [('VALIGN',(0,0),(-1,-1),'TOP')]
     584            )
    577585
    578586        pdf = canvas.Canvas('application_slip.pdf',pagesize=A4)
     587        pdf.setTitle(self.label)
     588        pdf.setSubject('Application')
     589        pdf.setAuthor('%s (%s)' % (self.request.principal.title,
     590            self.request.principal.id))
     591        pdf.setCreator('WAeUP SIRP')
    579592        width, height = A4
    580593        style = getSampleStyleSheet()
     594        pdf.line(1*cm,height-(1.3*cm),width-(1*cm),height-(1.3*cm))
    581595
    582596        story = []
    583         frame_header = Frame(1*cm,1*cm,width-(4*cm),height-(1*cm))
     597        frame_header = Frame(1*cm,1*cm,width-(2*cm),height-(1.2*cm))
    584598        header_title = getattr(grok.getSite(), 'name', u'Sample University')
    585599        story.append(Paragraph(header_title, style["Heading1"]))
     
    588602
    589603        story = []
    590         frame_body = Frame(1*cm,1*cm,width-(4*cm),height-(3*cm))
    591         story.append(Paragraph(self.label, style["Title"]))
    592         story.append(HRFlowable())
     604        frame_body = Frame(1*cm,1*cm,width-(2*cm),height-(3.1*cm))
     605        story.append(Paragraph(self.label, style["Heading2"]))
     606        #story.append(HRFlowable())
     607        story.append(Spacer(1, 18))
     608        for msg in self.context.history.messages:
     609            f_msg = '<font face="Courier" size=10>%s</font>' % msg
     610            story.append(Paragraph(f_msg, style["Normal"]))
    593611        story.append(Spacer(1, 24))
    594 
    595612        self.setUpWidgets()
    596 
    597613        data = []
    598614        for widget in self.widgets:
     
    605621            else:
    606622                filename = widget._data.file.name
    607                 im = Image(filename)
     623                im = Image(filename,width=4*cm, height=3*cm,kind='bound')
    608624                data.append([f_label,im])
    609625        f_label = '<font size=12>Admitted Course of Study</font>'
     
    612628        f_text = Paragraph(f_text, style["Normal"])
    613629        data.append([f_label,f_text])
    614         table = Table(data)
     630        table = Table(data,style=SLIP_STYLE)
    615631        story.append(table)
    616632        frame_body.addFromList(story,pdf)
     633
     634        story = []
     635        frame_footer = Frame(1*cm,0.5*cm,width-(2*cm),1*cm)
     636        timestamp = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
     637        f_text = '<font size=10>%s</font>' % timestamp
     638        story.append(Paragraph(f_text, style["Normal"]))
     639        frame_footer.addFromList(story,pdf)
    617640
    618641        self.response.setHeader(
Note: See TracChangeset for help on using the changeset viewer.