Ignore:
Timestamp:
20 Jun 2013, 19:41:56 (11 years ago)
Author:
Henrik Bettermann
Message:

Render two-column table of tables (not yet tested in custom packages).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py

    r10318 r10319  
    622622        return img
    623623
    624     def _getWidgetsTableData(self, widgets,
    625                              separators, domain, lang, table_style):
     624    def _getWidgetsTableData(self, widgets, separators, domain,
     625                             lang, table_style, twoDataCols):
    626626        row_num = 0
    627627        table_data = []
    628628        for widget in widgets:
    629             if separators and separators.get(widget.name):
     629            # We do not render headlines in multi-column design
     630            if twoDataCols is False and separators and separators.get(widget.name):
    630631                f_headline = translate(
    631632                    separators[widget.name], domain, target_language=lang)
    632633                f_headline = Paragraph(f_headline, HEADLINE1_STYLE)
    633                 table_data.append([f_headline ])
     634                table_data.append([f_headline])
    634635                table_style.append(('SPAN', (0,row_num), (-1,row_num)),)
    635636                table_style.append(
     
    676677           if these are given, we render extra rows with faculty and
    677678           department.
     679        - `colWidths`
     680           defines the the column widths of the data in the right column
     681           of base data (right to the passport image).
    678682        - `twoDataCols`
    679            render widgets in a parent table with two columns.
    680         """
    681         table_style = [#('LEFTPADDING', (0,0), (0,-1), 0), # indentation
    682                        ('VALIGN', (0,0), (-1,-1), 'TOP'),
     683           renders data widgets in a parent table with two columns.
     684        """
     685        table_style = [('VALIGN', (0,0), (-1,-1), 'TOP'),
    683686                       ]
    684687        widgets = self._setUpWidgets(form_fields, context)
     
    686689        # Determine table data
    687690        table_data, row_num, table_style = self._getWidgetsTableData(
    688             widgets, separators, domain, lang, table_style)
     691            widgets, separators, domain, lang, table_style, twoDataCols)
    689692
    690693        # Add course (admitted, etc.) if applicable
     
    696699            table_data, row_num, dept, faculty, lang, domain)
    697700
    698         # Create table
     701        # render two-column table of tables
     702        lines = len(table_data)
     703        middle = lines/2
     704        if twoDataCols is True and lines > 2:
     705            table_left = Table(table_data[:middle+1],
     706                               style=table_style, colWidths=[5*cm, 4*cm])
     707            table_right = Table(table_data[middle+1:],
     708                                style=table_style, colWidths=[5*cm, 4*cm])
     709            table_style.append(('LEFTPADDING', (0,0), (0,-1), 3*cm),)
     710            table = Table([[table_left, table_right],],style=table_style)
     711            return table
     712
     713        # render single table
    699714        table = Table(
    700715            table_data,style=table_style, colWidths=colWidths) #, rowHeights=14)
Note: See TracChangeset for help on using the changeset viewer.