Index: main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
===================================================================
--- main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py	(revision 16088)
+++ main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py	(revision 16100)
@@ -465,4 +465,149 @@
         return None
 
+    def renderPDFTranscript(self, view, filename='transcript.pdf',
+                  student=None,
+                  studentview=None,
+                  note=None,
+                  signatures=(),
+                  sigs_in_footer=(),
+                  digital_sigs=(),
+                  show_scans=True, topMargin=1.5,
+                  omit_fields=(),
+                  tableheader=None,
+                  no_passport=False,
+                  save_file=False):
+        """Render pdf slip of a transcripts.
+        """
+        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
+        # XXX: tell what the different parameters mean
+        style = getSampleStyleSheet()
+        creator = self.getPDFCreator(student)
+        data = []
+        doc_title = view.label
+        author = '%s (%s)' % (view.request.principal.title,
+                              view.request.principal.id)
+        footer_text = view.label.split('\n')
+        if len(footer_text) > 2:
+            # We can add a department in first line
+            footer_text = footer_text[1]
+        else:
+            # Only the first line is used for the footer
+            footer_text = footer_text[0]
+        if getattr(student, 'student_id', None) is not None:
+            footer_text = "%s - %s - " % (student.student_id, footer_text)
+
+        # Insert student data table
+        if student is not None:
+            #bd_translation = trans(_('Base Data'), portal_language)
+            #data.append(Paragraph(bd_translation, HEADING_STYLE))
+            data.append(render_student_data(
+                studentview, view.context,
+                omit_fields, lang=portal_language,
+                slipname=filename,
+                no_passport=no_passport))
+
+        transcript_data = view.context.getTranscriptData()
+        levels_data = transcript_data[0]
+
+        contextdata = []
+        f_label = trans(_('Course of Study:'), portal_language)
+        f_label = Paragraph(f_label, ENTRY1_STYLE)
+        f_text = formatted_text(view.context.certificate.longtitle)
+        f_text = Paragraph(f_text, ENTRY1_STYLE)
+        contextdata.append([f_label,f_text])
+
+        f_label = trans(_('Faculty:'), portal_language)
+        f_label = Paragraph(f_label, ENTRY1_STYLE)
+        f_text = formatted_text(
+            view.context.certificate.__parent__.__parent__.__parent__.longtitle)
+        f_text = Paragraph(f_text, ENTRY1_STYLE)
+        contextdata.append([f_label,f_text])
+
+        f_label = trans(_('Department:'), portal_language)
+        f_label = Paragraph(f_label, ENTRY1_STYLE)
+        f_text = formatted_text(
+            view.context.certificate.__parent__.__parent__.longtitle)
+        f_text = Paragraph(f_text, ENTRY1_STYLE)
+        contextdata.append([f_label,f_text])
+
+        f_label = trans(_('Entry Session:'), portal_language)
+        f_label = Paragraph(f_label, ENTRY1_STYLE)
+        f_text = formatted_text(
+            view.session_dict.get(view.context.entry_session))
+        f_text = Paragraph(f_text, ENTRY1_STYLE)
+        contextdata.append([f_label,f_text])
+
+        f_label = trans(_('Final Session:'), portal_language)
+        f_label = Paragraph(f_label, ENTRY1_STYLE)
+        f_text = formatted_text(
+            view.session_dict.get(view.context.current_session))
+        f_text = Paragraph(f_text, ENTRY1_STYLE)
+        contextdata.append([f_label,f_text])
+
+        f_label = trans(_('Entry Mode:'), portal_language)
+        f_label = Paragraph(f_label, ENTRY1_STYLE)
+        f_text = formatted_text(view.studymode_dict.get(
+            view.context.entry_mode))
+        f_text = Paragraph(f_text, ENTRY1_STYLE)
+        contextdata.append([f_label,f_text])
+
+        f_label = trans(_('Final Verdict:'), portal_language)
+        f_label = Paragraph(f_label, ENTRY1_STYLE)
+        f_text = formatted_text(view.studymode_dict.get(
+            view.context.current_verdict))
+        f_text = Paragraph(f_text, ENTRY1_STYLE)
+        contextdata.append([f_label,f_text])
+
+        f_label = trans(_('Cumulative GPA:'), portal_language)
+        f_label = Paragraph(f_label, ENTRY1_STYLE)
+        format_float = getUtility(IKofaUtils).format_float
+        cgpa = format_float(transcript_data[1], 3)
+        if student.state == GRADUATED:
+            f_text = formatted_text('%s (%s)' % (
+                cgpa, self.getClassFromCGPA(transcript_data[1], student)[1]))
+        else:
+            f_text = formatted_text('%s' % cgpa)
+        f_text = Paragraph(f_text, ENTRY1_STYLE)
+        contextdata.append([f_label,f_text])
+
+        contexttable = Table(contextdata,style=SLIP_STYLE)
+        data.append(contexttable)
+
+        transcripttables = render_transcript_data(
+            view, tableheader, levels_data, lang=portal_language)
+        data.extend(transcripttables)
+
+        # Insert signatures
+        # XXX: We are using only sigs_in_footer in waeup.kofa, so we
+        # do not have a test for the following lines.
+        if signatures and not sigs_in_footer:
+            data.append(Spacer(1, 20))
+            # Render one signature table per signature to
+            # get date and signature in line.
+            for signature in signatures:
+                signaturetables = get_signature_tables(signature)
+                data.append(signaturetables[0])
+
+        # Insert digital signatures
+        if digital_sigs:
+            data.append(Spacer(1, 20))
+            sigs = digital_sigs.split('\n')
+            for sig in sigs:
+                data.append(Paragraph(sig, NOTE_STYLE))
+
+        view.response.setHeader(
+            'Content-Type', 'application/pdf')
+        try:
+            pdf_stream = creator.create_pdf(
+                data, None, doc_title, author=author, footer=footer_text,
+                note=note, sigs_in_footer=sigs_in_footer, topMargin=topMargin)
+        except IOError:
+            view.flash(_('Error in image file.'))
+            return view.redirect(view.url(view.context))
+        if save_file:
+            self._saveTranscriptPDF(student, pdf_stream)
+            return
+        return pdf_stream
+
     #: A tuple containing the names of registration states in which changing of
     #: passport pictures is allowed.
