pdf: add SignatureBlock(fullheight=) param
authorTero Marttila <terom@fixme.fi>
Thu, 30 Dec 2010 23:45:00 +0200
changeset 23 26ae1b1db3c7
parent 22 c68ca09b08b9
child 24 50a63155b244
pdf: add SignatureBlock(fullheight=) param
svv/pdf.py
--- a/svv/pdf.py	Thu Dec 30 23:44:10 2010 +0200
+++ b/svv/pdf.py	Thu Dec 30 23:45:00 2010 +0200
@@ -180,11 +180,12 @@
     # empty space to leave below the fields
     PADDING_BOTTOM = inch / 2
 
-    def __init__ (self, cols, fields, values) :
+    def __init__ (self, cols, fields, values={}, fullheight=None) :
         """
-            cols    - Column titles
-            fields  - Fields titles, describing the horizontal fields
-            values  - Pre-filled values as a {(col, field): value} dict
+            cols        - Column titles
+            fields      - Fields titles, describing the horizontal fields
+            values      - Pre-filled values as a {(col, field): value} dict
+            fullheight  - Consume full vertical height to place at bottom of page
 
             desc/value strings can contain formatting codes:
 
@@ -195,6 +196,7 @@
         self.cols = cols
         self.fields = fields
         self.values = values
+        self.fullheight = fullheight
 
     def wrap (self, width, height) :
         """
@@ -203,8 +205,11 @@
 
         self.width = width
 
-        # consume all available height, to place us at the bottom
-        self.height = max(len(self.fields) * self.FIELD_HEIGHT, height)
+        self.height = len(self.fields) * self.FIELD_HEIGHT
+
+        if self.fullheight :
+            # consume all available height, to place us at the bottom
+            self.height = max(self.height, height)
 
         return self.width, self.height