Changeset 10565 for main/waeup.kofa


Ignore:
Timestamp:
30 Aug 2013, 05:10:32 (11 years ago)
Author:
Henrik Bettermann
Message:

It's better to use a second pdf creator global utility for landscape formats. Then we can easily customize watermark and logo in custom packages in reports.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
3 edited

Legend:

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

    r10554 r10565  
    540540    logo_pos = [0, 0, 0]
    541541    logo_left_pos = [0, 0, 0]
     542    pagesize = portrait(A4)
    542543
    543544    @classmethod
     
    804805
    805806    def create_pdf(self, data, headerline=None, title=None, author=None,
    806                    footer='', note=None, sigs_in_footer=[], topMargin=1.5,
    807                    pagesize=portrait(A4)):
     807                   footer='', note=None, sigs_in_footer=[], topMargin=1.5):
    808808        """Returns a binary data stream which is a PDF document.
    809809        """
     
    815815            topMargin=topMargin*inch,
    816816            title=title,
    817             pagesize=pagesize,
     817            pagesize=self.pagesize,
    818818            showBoundary=False,
    819819            )
     
    835835        pdf_stream.close()
    836836        return result
     837
     838class LandscapePDFCreator(PDFCreator):
     839    """A utility to help with generating PDF docs in
     840    landscape format.
     841    """
     842    grok.name('landscape')
     843    pagesize = landscape(A4)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/level_report.py

    r10564 r10565  
    7070from reportlab.lib.units import cm
    7171from reportlab.platypus import Paragraph, Table, Spacer
    72 from reportlab.lib.pagesizes import A4, landscape
    7372from waeup.kofa.reports import IReport, IReportGenerator
    7473from waeup.kofa.reports import Report
     
    130129
    131130    def create_pdf(self):
    132         creator = getUtility(IPDFCreator)
     131        creator = getUtility(IPDFCreator, name='landscape')
    133132        table_data = tbl_data_to_table(self.data)
    134133        #col_widths = [3.5*cm] * len(self.data[0])
     
    146145            pdf_data, None, doc_title, self.author,
    147146            'Level Report %s/%s/%s/%s' % (
    148             self.faccode, self.depcode, self.levelcode, self.sessioncode),
    149             pagesize=landscape(A4))
     147            self.faccode, self.depcode, self.levelcode, self.sessioncode)
     148            )
    150149        return pdf
    151150
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_statistics.py

    r10559 r10565  
    8585from reportlab.lib.units import cm
    8686from reportlab.platypus import Paragraph, Table, Spacer
    87 from reportlab.lib.pagesizes import A4, landscape
    8887from waeup.kofa.reports import IReport, IReportGenerator
    8988from waeup.kofa.reports import Report
     
    136135
    137136    def create_pdf(self):
    138         creator = getUtility(IPDFCreator)
     137        creator = getUtility(IPDFCreator, name='landscape')
    139138        table_data = tbl_data_to_table(*self.data)
    140139        col_widths = [None,] + [1.6*cm] * len(self.data[1]) + [None,]
     
    147146        pdf = creator.create_pdf(
    148147            pdf_data, None, doc_title, self.author,
    149             'Students in Session %s' % self.session,
    150             pagesize=landscape(A4))
     148            'Students in Session %s' % self.session
     149            )
    151150        return pdf
    152151
Note: See TracChangeset for help on using the changeset viewer.