add DocTemplate support for viewer preferences; version --> 3.5.49
authorrobin
Wed, 02 Sep 2020 13:04:01 +0100
changeset 4600 1a445335470c
parent 4599 473d7d2b6d33
child 4601 f3e622b58a0c
add DocTemplate support for viewer preferences; version --> 3.5.49
CHANGES.md
src/reportlab/__init__.py
src/reportlab/pdfbase/pdfdoc.py
src/reportlab/platypus/doctemplate.py
tests/test_platypus_breaking.py
--- a/CHANGES.md	Wed Sep 02 13:00:43 2020 +0100
+++ b/CHANGES.md	Wed Sep 02 13:04:01 2020 +0100
@@ -11,6 +11,12 @@
 The contributors lists are in no order and apologies to those accidentally not
 mentioned. If we missed you, please let us know!
 
+RELEASE 3.5.49	 02/09/2020
+---------------------------
+	* ViewerPreferencesPDFDictionary add /Duplex as possibility
+	* Doctemplate add support for all ViewerPreferencesPDFDictionary keys
+	* fix bugs in USPS_4State; Barcode inherits from Flowable and object.
+
 RELEASE 3.5.48	 18/08/2020
 ---------------------------
 	* bug fix for balanced column special case unsplittable half column
--- a/src/reportlab/__init__.py	Wed Sep 02 13:00:43 2020 +0100
+++ b/src/reportlab/__init__.py	Wed Sep 02 13:04:01 2020 +0100
@@ -1,9 +1,9 @@
 #Copyright ReportLab Europe Ltd. 2000-2018
 #see license.txt for license details
 __doc__="""The Reportlab PDF generation library."""
-Version = "3.5.48"
+Version = "3.5.49"
 __version__=Version
-__date__='20200818'
+__date__='20200902'
 
 import sys, os
 
--- a/src/reportlab/pdfbase/pdfdoc.py	Wed Sep 02 13:00:43 2020 +0100
+++ b/src/reportlab/pdfbase/pdfdoc.py	Wed Sep 02 13:04:01 2020 +0100
@@ -969,7 +969,7 @@
             fs = format(s, document)
             L.append(fs)
         return pdfdocEnc(b''.join(L))
-		
+
 class PDFTrailer(PDFObject):
     def __init__(self, startxref, Size=None, Prev=None, Root=None, Info=None, ID=None, Encrypt=None):
         self.startxref = startxref
--- a/src/reportlab/platypus/doctemplate.py	Wed Sep 02 13:00:43 2020 +0100
+++ b/src/reportlab/platypus/doctemplate.py	Wed Sep 02 13:04:01 2020 +0100
@@ -506,6 +506,19 @@
                     'trimBox': None,
                     'bleedBox': None,
                     'keepTogetherClass': KeepTogether,
+                    'hideToolbar': None,
+                    'hideMenubar': None,
+                    'hideWindowUI': None,
+                    'fitWindow': None,
+                    'centerWindow': None,
+                    'nonFullScreenPageMode': None,
+                    'direction': None,
+                    'viewArea': None,
+                    'viewClip': None,
+                    'printArea': None,
+                    'printClip': None,
+                    'printScaling': None,
+                    'duplex': None,
                     }
     _invalidInitArgs = ()
     _firstPageTemplateIndex = 0
@@ -993,8 +1006,15 @@
         canv.setCreator(self.creator)
         canv.setProducer(self.producer)
         canv.setKeywords(self.keywords)
-        if self.displayDocTitle is not None:
-            canv.setViewerPreference('DisplayDocTitle',['false','true'][self.displayDocTitle])
+        from reportlab.pdfbase.pdfdoc import (
+                ViewerPreferencesPDFDictionary as VPD, checkPDFBoolean as cPDFB,
+                )
+        for k,vf in VPD.validate.items():
+            v = getattr(self,k[0].lower()+k[1:],None)
+            if v is not None:
+                if vf is cPDFB:
+                    v = ['false','true'][v] #convert to pdf form of boolean
+                canv.setViewerPreference(k,v)
 
         if self._onPage:
             canv.setPageCallBack(self._onPage)
--- a/tests/test_platypus_breaking.py	Wed Sep 02 13:00:43 2020 +0100
+++ b/tests/test_platypus_breaking.py	Wed Sep 02 13:04:01 2020 +0100
@@ -161,7 +161,10 @@
         return story
 
     for sfx,klass in (('',KeepTogether),('_ktsat',KeepTogetherSplitAtTop)):
-        doc = MyDocTemplate(outputfile('test_platypus_breaking%s.pdf'%sfx),keepTogetherClass=klass)
+        doc = MyDocTemplate(outputfile('test_platypus_breaking%s.pdf'%sfx),keepTogetherClass=klass,
+                displayDocTitle=(sfx==''),
+                duplex='Simplex',
+                )
         doc.multiBuild(makeStory())
 
 class BreakingTestCase(unittest.TestCase):