Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py	(revision 6357)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py	(revision 6358)
@@ -27,4 +27,5 @@
 from datetime import datetime
 from zope.formlib.widget import CustomWidgetFactory
+from zope.formlib.form import setUpEditWidgets
 from zope.securitypolicy.interfaces import IPrincipalRoleManager
 from zope.traversing.browser import absoluteURL
@@ -516,4 +517,68 @@
         return 'not yet admitted'
 
+class PDFActionButton(ManageActionButton):
+    grok.context(IApplicant)
+    grok.view(DisplayApplicant)
+    grok.require('waeup.handleApplication')
+    icon = 'actionicon_pdf.png'
+    text = 'Download pdf slip'
+    target = 'application_slip.pdf'
+
+class ExportPDFPage(grok.View):
+    """Deliver a PDF slip of the context.
+    """
+    grok.context(IApplicant)
+    grok.name('application_slip.pdf')
+    grok.require('waeup.handleApplication')
+    form_fields = grok.AutoFields(IApplicant).omit(
+        'locked').omit('course_admitted')
+    form_fields['passport'].custom_widget = ThumbnailWidget
+    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
+
+    prefix = 'form'
+
+    def getCourseAdmitted(self):
+        """Return title and code in html format to the certificate
+           admitted.
+        """
+        course_admitted = self.context.course_admitted
+        if ICertificate.providedBy(course_admitted):
+            title = course_admitted.title
+            code = course_admitted.code
+            return '%s (%s)' %(title,code)
+        return 'not yet admitted'
+
+    def setUpWidgets(self, ignore_request=False):
+        self.adapters = {}
+        self.widgets = setUpEditWidgets(
+            self.form_fields, self.prefix, self.context, self.request,
+            adapters=self.adapters, for_display=True,
+            ignore_request=ignore_request
+            )
+
+    # Render a demo pdf page
+    def render(self):
+        from reportlab.pdfgen import canvas
+        from reportlab.lib.units import cm
+        from reportlab.lib.pagesizes import A4, landscape
+        from reportlab.lib.styles import getSampleStyleSheet
+        from reportlab.platypus import Frame, Paragraph
+
+        pdf = canvas.Canvas('application_slip.pdf',pagesize=A4)
+        width, height = A4
+        style = getSampleStyleSheet()
+        story = []
+        frame = Frame(1*cm,1*cm,width-(2*cm),height-(2*cm))
+        self.setUpWidgets()
+        #import pdb; pdb.set_trace()
+        for widget in self.widgets:
+            if widget.name != 'form.passport':
+                ptext = widget()
+                story.append(Paragraph(ptext, style["Normal"]))
+        frame.addFromList(story,pdf)
+        self.response.setHeader(
+            'Content-Type', 'application/pdf')
+        return pdf.getpdfdata()
+
 class ApplicantsManageActionButton(ManageActionButton):
     grok.context(IApplicant)
@@ -574,29 +639,4 @@
         return
 
-class PDFActionButton(ManageActionButton):
-    grok.context(IApplicant)
-    grok.view(DisplayApplicant)
-    grok.require('waeup.handleApplication')
-    icon = 'actionicon_pdf.png'
-    text = 'Download pdf slip'
-    target = 'application_slip.pdf'
-
-class ExportPDFPage(grok.View):
-    """Deliver a PDF slip of the context.
-    """
-    grok.context(IApplicant)
-    grok.name('application_slip.pdf')
-    grok.require('waeup.handleApplication')
-
-    # Render a demo pdf pagge
-    def render(self):
-        #exporter = IWAeUPXMLExporter(self.context)
-        #xml = exporter.export().read()
-        pdf = canvas.Canvas("application_slip.pdf")
-        pdf.drawString(100,750,"Welcome to Reportlab!")
-        self.response.setHeader(
-            'Content-Type', 'application/pdf')
-        return pdf.getpdfdata()
-
 class EditApplicantStudent(EditApplicantFull):
     """An applicant-centered edit view for applicant data.
