src/reportlab/platypus/doctemplate.py
changeset 4212 c903815560d1
parent 4211 464df39467fc
child 4228 fd5bbccc7758
--- a/src/reportlab/platypus/doctemplate.py	Fri Jun 19 14:09:51 2015 +0100
+++ b/src/reportlab/platypus/doctemplate.py	Wed Jun 24 14:13:27 2015 +0100
@@ -251,7 +251,12 @@
     derived classes can also implement beforeDrawPage and afterDrawPage if they want
     """
     def __init__(self,id=None,frames=[],onPage=_doNothing, onPageEnd=_doNothing,
-                 pagesize=None, autoNextPageTemplate=None):
+                 pagesize=None, autoNextPageTemplate=None,
+                 cropBox=None,
+                 artBox=None,
+                 trimBox=None,
+                 bleedBox=None,
+                 ):
         frames = frames or []
         if not isSeq(frames): frames = [frames]
         assert [x for x in frames if not isinstance(x,Frame)]==[], "frames argument error"
@@ -261,6 +266,10 @@
         self.onPageEnd = onPageEnd
         self.pagesize = pagesize
         self.autoNextPageTemplate = autoNextPageTemplate
+        self.cropBox = cropBox
+        self.artBox = artBox
+        self.trimBox = trimBox
+        self.bleedBox = bleedBox
 
     def beforeDrawPage(self,canv,doc):
         """Override this if you want additional functionality or prefer
@@ -288,6 +297,10 @@
                 canv.setPageSize(self.pagesize)
             elif cp!=dp:
                 canv.setPageSize(doc.pagesize)
+        for box in 'crop','art','trim','bleed':
+            size = getattr(self,box+'Box',None)
+            if size:
+                canv.setCropBox(size,name=box)
 
     def afterDrawPage(self, canv, doc):
         """This is called after the last flowable for the page has
@@ -456,6 +469,10 @@
                     'initialFontName': None,
                     'initialFontSize': None,
                     'initialLeading': None,
+                    'cropBox': None,
+                    'artBox': None,
+                    'trimBox': None,
+                    'bleedBox': None,
                     }
     _invalidInitArgs = ()
     _firstPageTemplateIndex = 0
@@ -863,6 +880,10 @@
                                 initialFontName = self.initialFontName,
                                 initialFontSize = self.initialFontSize,
                                 initialLeading = self.initialLeading,
+                                cropBox = self.cropBox,
+                                artBox = self.artBox,
+                                trimBox = self.trimBox,
+                                bleedBox = self.bleedBox,
                                 )
 
         getattr(self.canv,'setEncrypt',lambda x: None)(self.encrypt)