Index: main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 9913)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 9916)
@@ -203,5 +203,11 @@
 
 def get_signature_table(signatures, lang='en'):
-    """Return a reportlab table containing signature fields (with date).
+    """Return a list of one or more reportlab tables with signature fields.
+
+    Each signature will get a date field.
+
+    If more than three signatures have to be rendered, instead of a
+    list with one table a list of tables with one signature field each
+    will be returned.
     """
     style = getSampleStyleSheet()
@@ -220,25 +226,40 @@
         ('TOPPADDING', (0,-1), (-1,-1), 0),
         ]
-    for num, elem in enumerate(signatures):
-        # draw a line above each signature cell (not: empty cells in between)
-        sig_style.append(
-            ('LINEABOVE', (num*2,-1), (num*2, -1), 1, colors.black))
+
+    col_widths = [sig_col_width*cm, space_width*cm] * len(signatures)
+    if len(signatures) == 1 or len(signatures) > 3:
+        col_widths = [table_width*0.66*cm, table_width*0.34*cm]
 
     row = []
-    for signature in signatures:
-        row.append(Paragraph(trans(_('Date:'), lang), ENTRY1_STYLE))
-        row.append('')
-        if len(signatures) > 1:
-            col_widths.extend([sig_col_width*cm, space_width*cm])
-        else:
-            col_widths.extend([sig_col_width/2*cm, sig_col_width/2*cm])
-            row.append('') # empty spaceholder on right
-    data.append(row[:-1])
-    data.extend(([''],)*2) # insert 2 empty rows...
-    row = []
-    for signature in signatures:
-        row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
-        row.append('')
-    data.append(row[:-1])
+    if len(signatures) < 4:
+        # draw several signature fields in a row
+        for num, signature in enumerate(signatures):
+            # draw a line above each signature cell (not: empty cells
+            # in between)
+            sig_style.append(
+                ('LINEABOVE', (num*2,-1), (num*2, -1), 1, colors.black))
+            row.append(Paragraph(trans(_('Date:'), lang), ENTRY1_STYLE))
+            row.append('') # space col
+        data.append(row[:-1])
+        data.extend(([''],)*2) # insert 2 empty rows...
+        row = []
+        for signature in signatures:
+            row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
+            row.append('')
+        data.append(row[:-1])
+    else:
+        # Draw each signature field one under another (vertically)
+        for num, signature in enumerate(signatures):
+            line = (num - 1) * 2
+            sig_style.extend((
+                ('TOPPADDING', (0, line), (-1, line), 32),
+                ('BOTTOMPADDING', (0, line), (-1, line), 2),
+                ('LINEABOVE', (0, line+1), (0, line+1), 1, colors.black),
+                ('SPAN', (0, line+1), (1, line+1)),
+                ))
+            data.append(['', ''])
+            row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
+            data.append(row)
+            row = []
     table = Table(data, style=sig_style, repeatRows=len(data),
                   colWidths=col_widths)
@@ -355,7 +376,7 @@
                 return _('Study course data are incomplete.'), None
             if previous_session:
-                # Students can pay for previous sessions in all workflow states.
-                # Fresh students are excluded by the update method of the
-                # PreviousPaymentAddFormPage.
+                # Students can pay for previous sessions in all
+                # workflow states.  Fresh students are excluded by the
+                # update method of the PreviousPaymentAddFormPage.
                 if previous_level == 100:
                     amount = getattr(certificate, 'school_fee_1', 0.0)
@@ -366,19 +387,25 @@
                     amount = getattr(certificate, 'school_fee_1', 0.0)
                 elif student.state == RETURNING:
-                    # In case of returning school fee payment the payment session
-                    # and level contain the values of the session the student
-                    # has paid for. Payment session is always next session.
+                    # In case of returning school fee payment the
+                    # payment session and level contain the values of
+                    # the session the student has paid for. Payment
+                    # session is always next session.
                     p_session, p_level = self.getReturningData(student)
                     academic_session = self._getSessionConfiguration(p_session)
                     if academic_session == None:
-                        return _(u'Session configuration object is not available.'), None
+                        return _(
+                            u'Session configuration object is not available.'
+                            ), None
                     amount = getattr(certificate, 'school_fee_2', 0.0)
                 elif student.is_postgrad and student.state == PAID:
-                    # Returning postgraduate students also pay for the next session
-                    # but their level always remains the same.
+                    # Returning postgraduate students also pay for the
+                    # next session but their level always remains the
+                    # same.
                     p_session += 1
                     academic_session = self._getSessionConfiguration(p_session)
                     if academic_session == None:
-                        return _(u'Session configuration object is not available.'), None
+                        return _(
+                            u'Session configuration object is not available.'
+                            ), None
                     amount = getattr(certificate, 'school_fee_2', 0.0)
         elif category == 'clearance':
@@ -554,4 +581,5 @@
         """Render pdf slips for various pages.
         """
+        # XXX: tell what the different parameters mean
         style = getSampleStyleSheet()
         creator = getUtility(IPDFCreator)
