- Timestamp:
- 14 Jun 2011, 07:48:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r6363 r6364 33 33 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 34 34 from reportlab.pdfgen import canvas 35 from reportlab.lib.units import cm 36 from reportlab.lib.pagesizes import A4, landscape 37 from reportlab.lib.styles import getSampleStyleSheet 38 from reportlab.platypus import (Frame, Paragraph, Image, 39 Table, Spacer) 40 from reportlab.platypus.flowables import HRFlowable 41 from reportlab.platypus.tables import TableStyle 35 42 36 43 from waeup.sirp.accesscodes import invalidate_accesscode … … 568 575 569 576 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 ) 577 585 578 586 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') 579 592 width, height = A4 580 593 style = getSampleStyleSheet() 594 pdf.line(1*cm,height-(1.3*cm),width-(1*cm),height-(1.3*cm)) 581 595 582 596 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)) 584 598 header_title = getattr(grok.getSite(), 'name', u'Sample University') 585 599 story.append(Paragraph(header_title, style["Heading1"])) … … 588 602 589 603 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"])) 593 611 story.append(Spacer(1, 24)) 594 595 612 self.setUpWidgets() 596 597 613 data = [] 598 614 for widget in self.widgets: … … 605 621 else: 606 622 filename = widget._data.file.name 607 im = Image(filename )623 im = Image(filename,width=4*cm, height=3*cm,kind='bound') 608 624 data.append([f_label,im]) 609 625 f_label = '<font size=12>Admitted Course of Study</font>' … … 612 628 f_text = Paragraph(f_text, style["Normal"]) 613 629 data.append([f_label,f_text]) 614 table = Table(data )630 table = Table(data,style=SLIP_STYLE) 615 631 story.append(table) 616 632 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) 617 640 618 641 self.response.setHeader(
Note: See TracChangeset for help on using the changeset viewer.