Changeset 8257


Ignore:
Timestamp:
23 Apr 2012, 11:56:06 (13 years ago)
Author:
uli
Message:

Support notes in generated PDFs.

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

Legend:

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

    r8103 r8257  
    9797        return data
    9898
    99     def __call__(self, view=None):
     99    def __call__(self, view=None, note=None):
    100100        """Return a PDF representation of the context applicant.
    101101
     
    133133        # append comments
    134134        data = self._addComments(data)
    135         return creator.create_pdf(data, None, doc_title)
     135
     136        return creator.create_pdf(data, None, doc_title, note=note)
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/interfaces.py

    r8059 r8257  
    178178        """A callback function to render background of PDFs.
    179179        """
    180     def create_pdf(data, headerline=None, title=None):
     180    def create_pdf(data, headerline=None, title=None, note=None):
    181181        """Create a PDF.
    182182
     
    188188        the top bar.
    189189
     190        `note` is optional HTML markup added at bottom of created
     191        document.
     192
    190193        If no `headerline` is given, a default will be rendered (name
    191194        of university).
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py

    r8234 r8257  
    7171    )
    7272
     73#: A reportlab paragraph style for notes output at end of documents.
     74NOTE_STYLE = ParagraphStyle(
     75    name='Note',
     76    parent=NORMAL_STYLE,
     77    fontName='Helvetica',
     78    fontSize=12,
     79    )
     80
    7381def format_html(html):
    7482    """Make HTML code usable for use in reportlab paragraphs.
     
    349357
    350358    def create_pdf(self, data, headerline=None, title=None, author=None,
    351                    footer=''):
     359                   footer='', note=None):
    352360        """Returns a binary data stream which is a PDF document.
    353361        """
     
    367375        doc.kofa_author = author
    368376        doc.kofa_footer = footer
     377        if note is not None:
     378            html = format_html(note)
     379            data.append(Paragraph(html, NOTE_STYLE))
    369380        doc.build(data, onFirstPage=self.paint_background,
    370381                  onLaterPages=self.paint_background,
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r8246 r8257  
    10201020    """
    10211021
    1022     def __call__(view=None):
     1022    def __call__(view=None, note=None):
    10231023        """Create a bytestream representing a PDF from context.
    10241024
    10251025        If `view` is passed in additional infos might be rendered into
    10261026        the document.
     1027
     1028        `note` is optional HTML rendered at bottom of the created
     1029        PDF. Please consider the limited reportlab support for HTML,
     1030        but using font-tags and friends you certainly can get the
     1031        desired look.
    10271032        """
    10281033
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r8244 r8257  
    311311        return available_beds[0]
    312312
    313     def renderPDF(self, view, filename='slip.pdf',
    314         student=None, studentview=None, tableheader=None, tabledata=None):
     313    def renderPDF(self, view, filename='slip.pdf', student=None,
     314                  studentview=None, tableheader=None, tabledata=None,
     315                  note=None):
    315316        """Render pdf slips for various pages.
    316317        """
     
    359360        try:
    360361            pdf_stream = creator.create_pdf(
    361                 data, None, doc_title, author=author, footer=footer_text)
     362                data, None, doc_title, author=author, footer=footer_text,
     363                note=note)
    362364        except IOError:
    363365            view.flash('Error in image file.')
Note: See TracChangeset for help on using the changeset viewer.