Ignore:
Timestamp:
6 Nov 2012, 00:05:27 (12 years ago)
Author:
uli
Message:

Add sig_in_footer option for generated PDFs.

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

Legend:

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

    r9452 r9547  
    203203
    204204    @classmethod
     205    def _drawSignatureBoxes(cls, canvas, width, height, signatures=[]):
     206        """Draw signature boxes into canvas.
     207        """
     208        canvas.saveState()
     209        canvas.setFont("Helvetica", 10)
     210        canvas.drawString(
     211            2.2*cm + 0.2*cm, 1.35 * inch,
     212            translate(_('Date, Student Signature')))
     213        canvas.drawString(
     214            width/2.0 + 0.15*cm + 0.4*cm, 1.35 * inch,
     215            translate(_('Date, Clearance Officer Signature')))
     216        canvas.rect(2.2*cm, 0.75*inch, width/2.0-2.1*cm, 0.75*inch)
     217        canvas.rect(width/2.0+0.3*cm, 0.75*inch, width/2.0-2.5*cm, 0.75*inch)
     218        canvas.restoreState()
     219        return canvas
     220
     221    @classmethod
    205222    def fromStringList(cls, string_list):
    206223        """Generate a list of reportlab paragraphs out of a list of strings.
     
    344361        # Footer
    345362        canvas.saveState()
     363        if getattr(doc, 'sig_in_footer', False):
     364            self._drawSignatureBoxes(canvas, width, height)
    346365        canvas.line(2.2*cm, 0.62*inch, width-2.2*cm, 0.62*inch)
    347366        canvas.setFont("Helvetica", 9)
     
    365384
    366385    def create_pdf(self, data, headerline=None, title=None, author=None,
    367                    footer='', note=None):
     386                   footer='', note=None, sig_in_footer=False):
    368387        """Returns a binary data stream which is a PDF document.
    369388        """
    370389        pdf_stream = StringIO()
     390        bottomMargin = sig_in_footer and 1.4*inch or 0.8*inch
    371391        doc = SimpleDocTemplate(
    372392            pdf_stream,
    373             bottomMargin=1.1*inch,
     393            bottomMargin=bottomMargin,
    374394            topMargin=1.3*inch,
    375395            title=title,
     
    383403        doc.kofa_author = author
    384404        doc.kofa_footer = footer
     405        doc.sig_in_footer = sig_in_footer
    385406        if note is not None:
    386407            html = format_html(note)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9532 r9547  
    506506    def renderPDF(self, view, filename='slip.pdf', student=None,
    507507                  studentview=None, tableheader=None, tabledata=None,
    508                   note=None, signatures=None):
     508                  note=None, signatures=None, sig_in_footer=False):
    509509        """Render pdf slips for various pages.
    510510        """
     
    557557
    558558        # Insert signatures
    559         if signatures:
     559        if signatures and not sig_in_footer:
    560560            data.append(Spacer(1, 20))
    561561            signaturetable = get_signature_table(signatures)
     
    567567            pdf_stream = creator.create_pdf(
    568568                data, None, doc_title, author=author, footer=footer_text,
    569                 note=note)
     569                note=note, sig_in_footer=sig_in_footer)
    570570        except IOError:
    571571            view.flash('Error in image file.')
Note: See TracChangeset for help on using the changeset viewer.