Ignore:
Timestamp:
11 Apr 2012, 09:38:18 (13 years ago)
Author:
uli
Message:

Support metadata and footer text when creating PDFs.

File:
1 edited

Legend:

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

    r8102 r8104  
    285285        canvas.drawRightString(
    286286            width-2.2*cm, 0.5 * inch,
    287             translate(_(u'page ${a}' , mapping = {'a':doc.page})))
     287            translate(_(u'${b} Page ${a}' , mapping = {'a':doc.page,
     288                                                       'b':doc.kofa_footer})))
    288289        canvas.restoreState()
    289290        canvas.restoreState()
     291
     292        # Metadata
     293        canvas.setAuthor(getattr(doc, 'kofa_author', 'Unknown'))
     294        canvas.setSubject(title)
     295        canvas.setCreator(u'WAeUP Kofa')
    290296        return
    291297
    292     def create_pdf(self, data, headerline=None, title=None):
     298    def create_pdf(self, data, headerline=None, title=None, author=None,
     299                   footer=''):
    293300        """Returns a binary data stream which is a PDF document.
    294301        """
     
    308315            doc.kofa_headtitle = headerline
    309316        doc.kofa_title = title
     317        doc.kofa_author = author
     318        doc.kofa_footer = footer
    310319        doc.build(data, onFirstPage=self.paint_background,
    311320                  onLaterPages=self.paint_background)
Note: See TracChangeset for help on using the changeset viewer.