reportlab/platypus/doctemplate.py
changeset 2666 a72c25280be2
parent 2664 c9faa3a99e93
child 2670 3fdd642a7b76
--- a/reportlab/platypus/doctemplate.py	Fri Jul 21 12:45:38 2006 +0000
+++ b/reportlab/platypus/doctemplate.py	Sat Jul 29 11:33:20 2006 +0000
@@ -316,6 +316,8 @@
                     'allowSplitting':1,
                     'title':None,
                     'author':None,
+                    'subject':None,
+                    'keywords':[],
                     'invariant':None,
                     'pageCompression':None,
                     '_pageBreakQuick':1,
@@ -675,11 +677,18 @@
                                 pagesize=self.pagesize,
                                 invariant=self.invariant,
                                 pageCompression=self.pageCompression)
+
+        self.canv.setAuthor(self.author)
+        self.canv.setTitle(self.title)
+        self.canv.setSubject(self.subject)
+        self.canv.setKeywords(self.keywords)
+        
         if self._onPage:
             self.canv.setPageCallBack(self._onPage)
         self.handle_documentBegin()
 
     def _endBuild(self):
+        print 'start of doc._endBuild: keywords=', self.canv._doc.info.keywords
         if self._hanging!=[] and self._hanging[-1] is PageBegin:
             del self._hanging[-1]
             self.clean_hanging()
@@ -707,11 +716,18 @@
             self._onProgress('SIZE_EST', len(flowables))
         self._startBuild(filename,canvasmaker)
 
+        #pagecatcher can drag in information from embedded PDFs and we want ours
+        #to take priority, so cache and reapply our own info dictionary after the build.
+        self._savedInfo = self.canv._doc.info
+        handled = 0
         while len(flowables):
             self.clean_hanging()
             try:
                 first = flowables[0]
                 self.handle_flowable(flowables)
+                handled += 1
+
+
             except:
                 #if it has trace info, add it to the traceback message.
                 if hasattr(first, '_traceInfo') and first._traceInfo:
@@ -730,6 +746,9 @@
             if self._onProgress:
                 self._onProgress('PROGRESS',flowableCount - len(flowables))
 
+        #reapply pagecatcher info
+        self.canv._doc.info = self._savedInfo 
+
         self._endBuild()
         if self._onProgress:
             self._onProgress('FINISHED',0)