Commits

Michael P. Jung committed d9e0878

Add infobox

Comments (0)

Files changed (3)

dinbrief/document.py

         # Content
         self.sender = kwargs.pop('sender', self.sender or [])
         self.recipient = kwargs.pop('recipient', self.recipient or [])
+        self.infobox = kwargs.pop('infobox', [])
         self.date = kwargs.pop('date', self.date)
         self.content = kwargs.pop('content', self.content or [])

dinbrief/styles.py

 styles.add(ParagraphStyle(
     name='InfoboxTitle',
     parent=styles['Normal'],
-    fontSize=7,
+    fontSize=8,
     leading=8,
-    spaceAfter=0,
-    textColor=colors.white))
+    spaceAfter=0.5*mm))
 
 styles.add(ParagraphStyle(
     name='InfoboxText',
     parent=styles['Normal'],
     fontSize=10,
-    leading=10,
-    spaceAfter=1.5*mm,
-    textColor=colors.white))
+    leading=12,
+    spaceAfter=2*mm))
+
+styles.add(ParagraphStyle(
+    name='InfoboxNotice',
+    parent=styles['Normal'],
+    fontName='Helvetica-Bold',
+    fontSize=10,
+    spaceBefore=4*mm,
+    spaceAfter=4*mm))
 
 styles.add(ParagraphStyle(
     name='Footer',

dinbrief/template.py

 from reportlab.platypus import TableStyle
 
 from .constants import PAGE_SIZE, PAGE_WIDTH, PAGE_HEIGHT
-from .constants import CONTENT_LEFT, CONTENT_WIDTH
+from .constants import CONTENT_LEFT, CONTENT_RIGHT, CONTENT_WIDTH
 from .styles import styles
 
 
 RECIPIENT_HEIGHT = ADDRESS_HEIGHT - 10*mm
 RECIPIENT_WIDTH = PAGE_WIDTH - ADDRESS_X
 
+INFOBOX_WIDTH = 85*mm
+INFOBOX_HEIGHT = 100*mm
+INFOBOX_X = PAGE_WIDTH - INFOBOX_WIDTH - CONTENT_RIGHT
+INFOBOX_Y = PAGE_HEIGHT - INFOBOX_HEIGHT - 20*mm
+
 DATE_Y = 45*mm
 DATE_HEIGHT = PAGE_HEIGHT-140*mm
 
                     styles['Recipient']),
                 canvas)
 
+    def draw_infobox(self, canvas):
+        infobox = Frame(
+                INFOBOX_X, INFOBOX_Y,
+                INFOBOX_WIDTH, INFOBOX_HEIGHT,
+                0, 0, 0, 0)
+        for floatable in self.document.infobox:
+            infobox.add(floatable, canvas)
+
     def draw_date(self, canvas):
         frame = Frame(
                 CONTENT_LEFT, DATE_Y,
                     styles['Date']),
                 canvas)
 
-
     def afterDrawPage(self, canvas, document):
         BasePageTemplate.afterDrawPage(self, canvas, document)
         self.draw_address(canvas)
+        self.draw_infobox(canvas)
         self.draw_date(canvas)