Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py	(revision 7391)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py	(revision 7392)
@@ -23,5 +23,5 @@
 from time import time
 from datetime import datetime, date
-from zope.component import getUtility, createObject
+from zope.component import getUtility, createObject, getAdapter
 from zope.formlib.form import setUpEditWidgets
 from hurry.workflow.interfaces import (
@@ -50,5 +50,5 @@
 from waeup.sirp.browser.viewlets import ManageActionButton, PrimaryNavTab
 from waeup.sirp.interfaces import (
-    ISIRPObject, ILocalRolesAssignable, IExtFileStore,
+    ISIRPObject, ILocalRolesAssignable, IExtFileStore, IPDF,
     IFileStoreNameChooser, IPasswordValidator, IUserAccount, ISIRPUtils)
 from waeup.sirp.permissions import get_users_with_local_roles
@@ -707,94 +707,9 @@
 
     def render(self):
-        # To recall the table coordinate system:
-        # (0,0),(-1,-1) = whole table
-        # (0,0),(0,-1) = first column
-        # (-1,0),(-1,-1) = last column
-        # (0,0),(-1,0) = first row
-        # (0,-1),(-1,-1) = last row
-
-        SLIP_STYLE = TableStyle(
-            [('VALIGN',(0,0),(-1,-1),'TOP')]
-            )
-
-        pdf = canvas.Canvas('application_slip.pdf',pagesize=A4)
-        pdf.setTitle(self.label)
-        pdf.setSubject('Application')
-        pdf.setAuthor('%s (%s)' % (self.request.principal.title,
-            self.request.principal.id))
-        pdf.setCreator('SIRP SIRP')
-        width, height = A4
-        style = getSampleStyleSheet()
-        pdf.line(1*cm,height-(1.8*cm),width-(1*cm),height-(1.8*cm))
-
-        story = []
-        frame_header = Frame(1*cm,1*cm,width-(1.7*cm),height-(1.7*cm))
-        header_title = getattr(grok.getSite(), 'name', u'Sample University')
-        story.append(Paragraph(header_title, style["Heading1"]))
-        frame_header.addFromList(story,pdf)
-
-        story = []
-        frame_body = Frame(1*cm,1*cm,width-(2*cm),height-(3.5*cm))
-        story.append(Paragraph(self.label, style["Heading2"]))
-        story.append(Spacer(1, 18))
-        for msg in self.context.history.messages:
-            f_msg = '<font face="Courier" size=10>%s</font>' % msg
-            story.append(Paragraph(f_msg, style["Normal"]))
-        story.append(Spacer(1, 24))
-        # Setup table data
-        data = []
-        # Insert passport photograph
-        img = getUtility(IExtFileStore).getFileByContext(self.context)
-        if img is None:
-            img = open(DEFAULT_PASSPORT_IMAGE_PATH, 'rb')
-        doc_img = Image(img.name, width=4*cm, height=3*cm, kind='bound')
-        data.append([doc_img])
-        data.append([Spacer(1, 18)])
-        # Render widget fields
-        self.setUpWidgets()
-        for widget in self.widgets:
-            f_label = '<font size=12>%s</font>:' % widget.label.strip()
-            f_label = Paragraph(f_label, style["Normal"])
-            f_text = '<font size=12>%s</font>' % widget()
-            f_text = Paragraph(f_text, style["Normal"])
-            data.append([f_label,f_text])
-        course_admitted = self.getCourseAdmitted()
-        f_label = '<font size=12>Admitted Course of Study:</font>'
-        f_text = '<font size=12>%s</font>' % course_admitted
-        f_label = Paragraph(f_label, style["Normal"])
-        f_text = Paragraph(f_text, style["Normal"])
-        data.append([f_label,f_text])
-
-        course_admitted = self.context.course_admitted
-        if getattr(course_admitted, '__parent__',None):
-            f_label = '<font size=12>Department:</font>'
-            f_text = '<font size=12>%s</font>' % (
-                course_admitted.__parent__.__parent__.longtitle())
-            f_label = Paragraph(f_label, style["Normal"])
-            f_text = Paragraph(f_text, style["Normal"])
-            data.append([f_label,f_text])
-
-            f_label = '<font size=12>Faculty:</font>'
-            f_text = '<font size=12>%s</font>' % (
-                course_admitted.__parent__.__parent__.__parent__.longtitle())
-            f_label = Paragraph(f_label, style["Normal"])
-            f_text = Paragraph(f_text, style["Normal"])
-            data.append([f_label,f_text])
-
-        # Create table
-        table = Table(data,style=SLIP_STYLE)
-        story.append(table)
-        frame_body.addFromList(story,pdf)
-
-        story = []
-        frame_footer = Frame(1*cm,0,width-(2*cm),1*cm)
-        timestamp = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
-        f_text = '<font size=10>%s</font>' % timestamp
-        story.append(Paragraph(f_text, style["Normal"]))
-        frame_footer.addFromList(story,pdf)
-
+        pdfstream = getAdapter(self.context, IPDF, name='application_slip')(
+            view=self)
         self.response.setHeader(
             'Content-Type', 'application/pdf')
-        return pdf.getpdfdata()
+        return pdfstream
 
 class ApplicantManageActionButton(ManageActionButton):
