Index: main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py	(revision 15834)
+++ main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py	(revision 15880)
@@ -802,5 +802,4 @@
         if not getattr(doc, 'kofa_nodate', False):
             tz = getattr(queryUtility(IKofaUtils), 'tzinfo', pytz.utc)
-            #tz = getUtility(IKofaUtils).tzinfo
             today = now(tz).strftime('%d/%m/%Y %H:%M:%S %Z')
             canvas.drawString(2.2*cm, 0.5 * inch,
@@ -811,5 +810,4 @@
         canvas.kofa_footer_text =  doc.kofa_footer
         canvas.restoreState()
-        canvas.restoreState()
 
         # Metadata
@@ -820,10 +818,14 @@
 
     def create_pdf(self, data, headerline=None, title=None, author=None,
-                   footer='', note=None, sigs_in_footer=[], topMargin=1.5):
+                   footer='', note=None, sigs_in_footer=[], topMargin=1.5,
+                   letterhead_path=None):
         """Returns a binary data stream which is a PDF document.
         """
         pdf_stream = StringIO()
         bottomMargin = len(sigs_in_footer) and 1.9*inch or 1.2*inch
-        topMargin += title.count('\n') * 0.2
+        if letterhead_path:
+            topMargin += 1.2
+        else:
+            topMargin += title.count('\n') * 0.2
         doc = SimpleDocTemplate(
             pdf_stream,
@@ -841,4 +843,5 @@
         doc.kofa_footer = footer
         doc.sigs_in_footer = sigs_in_footer
+        doc.letterhead_path = letterhead_path
         if note is not None:
             html = format_html(note)
@@ -859,4 +862,60 @@
     pagesize = landscape(A4)
 
+class LetterPDFCreator(PDFCreator):
+    """A utility to help with generating PDF docs with an original letterhead.
+    """
+    grok.name('letter')
+    letterhead_pos = [0, 0]
+
+    def paint_background(self, canvas, doc):
+        """Paint letterhead background of a PDF.
+
+        The `doc` is expected to be some reportlab SimpleDocTemplate
+        or similar object.
+
+        This is a callback method that will be called from reportlab
+        when creating PDFs with :meth:`create_pdf`.
+        """
+        canvas.saveState()
+        width, height = doc.width, doc.height
+        width += doc.leftMargin + doc.rightMargin
+        height += doc.topMargin + doc.bottomMargin
+
+        # Letterhead
+        if doc.letterhead_path is not None:
+            canvas.saveState()
+            canvas.drawImage(doc.letterhead_path,
+                self.letterhead_pos[0], self.letterhead_pos[1],
+                width=width, height=height)
+            canvas.restoreState()
+
+        # Footer
+        if getattr(doc, 'sigs_in_footer', False):
+            self._drawSignatureBoxes(
+                canvas, width, height, doc.sigs_in_footer)
+        #canvas.line(2.2*cm, 0.62*inch, width-2.2*cm, 0.62*inch)
+        canvas.setFont("Helvetica", 9)
+        if not getattr(doc, 'kofa_nodate', False):
+            tz = getattr(queryUtility(IKofaUtils), 'tzinfo', pytz.utc)
+            today = now(tz).strftime('%d/%m/%Y %H:%M:%S %Z')
+            #canvas.drawString(2.2*cm, 0.5 * inch,
+            #    translate(_(u'Date: ${a}', mapping = {'a': today})))
+            canvas.drawString(2.2*cm, 0.3 * inch,
+                translate(_(u'Date: ${a}', mapping = {'a': today})))
+        # set canves attributes needed to render `page x of y`
+        canvas.kofa_footer_x_pos = width-2.2*cm
+        #canvas.kofa_footer_y_pos = 0.5 * inch
+        canvas.kofa_footer_y_pos = 0.3 * inch
+        canvas.kofa_footer_text =  doc.kofa_footer
+        canvas.restoreState()
+
+        # Metadata
+        title = getattr(doc, 'kofa_title', '')
+        canvas.setAuthor(getattr(doc, 'kofa_author', 'Unknown'))
+        canvas.setSubject(title)
+        canvas.setCreator(u'WAeUP Kofa')
+        return
+
+
 class A3LandscapePDFCreator(LandscapePDFCreator):
     """A utility to help with generating PDF docs in
