src/reportlab/platypus/doctemplate.py
changeset 4405 c985bd7093ad
parent 4380 831ee16f2338
child 4458 dfef5530196d
equal deleted inserted replaced
4404:b055f51699ca 4405:c985bd7093ad
   937     _handle_flowable = handle_flowable
   937     _handle_flowable = handle_flowable
   938     _handle_nextPageTemplate = handle_nextPageTemplate
   938     _handle_nextPageTemplate = handle_nextPageTemplate
   939     _handle_currentFrame = handle_currentFrame
   939     _handle_currentFrame = handle_currentFrame
   940     _handle_nextFrame = handle_nextFrame
   940     _handle_nextFrame = handle_nextFrame
   941 
   941 
       
   942     def _makeCanvas(self, filename=None, canvasmaker=canvas.Canvas):
       
   943         '''make and return a sample canvas. As suggested by 
       
   944         Chris Jerdonek cjerdonek @ bitbucket this allows testing of stringWidths
       
   945         etc.
       
   946 
       
   947         *NB* only the canvases created in self._startBuild will actually be used
       
   948         in the build process.
       
   949         '''
       
   950         canv = canvasmaker(filename or self.filename,
       
   951                             pagesize=self.pagesize,
       
   952                             invariant=self.invariant,
       
   953                             pageCompression=self.pageCompression,
       
   954                             enforceColorSpace=self.enforceColorSpace,
       
   955                             initialFontName = self.initialFontName,
       
   956                             initialFontSize = self.initialFontSize,
       
   957                             initialLeading = self.initialLeading,
       
   958                             cropBox = self.cropBox,
       
   959                             artBox = self.artBox,
       
   960                             trimBox = self.trimBox,
       
   961                             bleedBox = self.bleedBox,
       
   962                             )
       
   963 
       
   964         getattr(canv,'setEncrypt',lambda x: None)(self.encrypt)
       
   965 
       
   966         canv._cropMarks = self.cropMarks
       
   967         canv.setAuthor(self.author)
       
   968         canv.setTitle(self.title)
       
   969         canv.setSubject(self.subject)
       
   970         canv.setCreator(self.creator)
       
   971         canv.setKeywords(self.keywords)
       
   972         if self.displayDocTitle is not None:
       
   973             canv.setViewerPreference('DisplayDocTitle',['false','true'][self.displayDocTitle])
       
   974         if self.lang:
       
   975             canv.setCatalogEntry('Lang',self.lang)
       
   976 
       
   977         if self._onPage:
       
   978             canv.setPageCallBack(self._onPage)
       
   979         return canv
       
   980 
   942     def _startBuild(self, filename=None, canvasmaker=canvas.Canvas):
   981     def _startBuild(self, filename=None, canvasmaker=canvas.Canvas):
   943         self._calc()
   982         self._calc()
   944 
   983 
   945         #each distinct pass gets a sequencer
   984         #each distinct pass gets a sequencer
   946         self.seq = reportlab.lib.sequencer.Sequencer()
   985         #self.seq = reportlab.lib.sequencer.Sequencer()
   947 
   986 
   948         self.canv = canvasmaker(filename or self.filename,
   987         self.canv = self._makeCanvas(filename=filename,canvasmaker=canvasmaker)
   949                                 pagesize=self.pagesize,
       
   950                                 invariant=self.invariant,
       
   951                                 pageCompression=self.pageCompression,
       
   952                                 enforceColorSpace=self.enforceColorSpace,
       
   953                                 initialFontName = self.initialFontName,
       
   954                                 initialFontSize = self.initialFontSize,
       
   955                                 initialLeading = self.initialLeading,
       
   956                                 cropBox = self.cropBox,
       
   957                                 artBox = self.artBox,
       
   958                                 trimBox = self.trimBox,
       
   959                                 bleedBox = self.bleedBox,
       
   960                                 )
       
   961 
       
   962         getattr(self.canv,'setEncrypt',lambda x: None)(self.encrypt)
       
   963 
       
   964         self.canv._cropMarks = self.cropMarks
       
   965         self.canv.setAuthor(self.author)
       
   966         self.canv.setTitle(self.title)
       
   967         self.canv.setSubject(self.subject)
       
   968         self.canv.setCreator(self.creator)
       
   969         self.canv.setKeywords(self.keywords)
       
   970         if self.displayDocTitle is not None:
       
   971             self.canv.setViewerPreference('DisplayDocTitle',['false','true'][self.displayDocTitle])
       
   972         if self.lang:
       
   973             self.canv.setCatalogEntry('Lang',self.lang)
       
   974 
       
   975         if self._onPage:
       
   976             self.canv.setPageCallBack(self._onPage)
       
   977         self.handle_documentBegin()
   988         self.handle_documentBegin()
   978 
   989 
   979     def _endBuild(self):
   990     def _endBuild(self):
   980         self._removeVars(('build','page','frame'))
   991         self._removeVars(('build','page','frame'))
   981         if self._hanging!=[] and self._hanging[-1] is PageBegin:
   992         if self._hanging!=[] and self._hanging[-1] is PageBegin: