merged in lang setting
authorrobin
Thu, 26 Sep 2019 13:44:55 +0100
changeset 4530 3f6cc4ae6211
parent 4528 e09377955af8 (current diff)
parent 4529 0e81d462d3b9 (diff)
child 4531 ea7eaa144e80
merged in lang setting
src/reportlab/pdfbase/pdfdoc.py
src/reportlab/platypus/doctemplate.py
--- a/src/reportlab/pdfbase/pdfdoc.py	Thu Sep 26 12:24:13 2019 +0100
+++ b/src/reportlab/pdfbase/pdfdoc.py	Thu Sep 26 13:44:55 2019 +0100
@@ -131,6 +131,7 @@
                  invariant=rl_config.invariant,
                  filename=None,
                  pdfVersion=PDF_VERSION_DEFAULT,
+                 lang=None,
                  ):
         self._ID = None
         self.objectcounter = 0
@@ -163,6 +164,7 @@
         cat = self.Catalog = self._catalog = PDFCatalog()
         pages = self.Pages = PDFPages()
         cat.Pages = pages
+        cat.Lang = PDFString(lang if lang else rl_config.documentLang)
         self.outline = self.Outlines = cat.Outlines = PDFOutlines0() if dummyoutline else PDFOutlines()
         self.info = PDFInfo()
         #self.Reference(self.Catalog)
--- a/src/reportlab/pdfgen/canvas.py	Thu Sep 26 12:24:13 2019 +0100
+++ b/src/reportlab/pdfgen/canvas.py	Thu Sep 26 13:44:55 2019 +0100
@@ -245,6 +245,7 @@
                  artBox=None,
                  trimBox=None,
                  bleedBox=None,
+                 lang=None,
                  ):
         """Create a canvas of a given size. etc.
 
@@ -273,6 +274,7 @@
         self._doc = pdfdoc.PDFDocument(compression=pageCompression,
                                        invariant=invariant, filename=filename,
                                        pdfVersion=pdfVersion or pdfdoc.PDF_VERSION_DEFAULT,
+                                       lang=lang
                                        )
 
         self._enforceColorSpace = _chooseEnforceColorSpace(enforceColorSpace)
--- a/src/reportlab/platypus/doctemplate.py	Thu Sep 26 12:24:13 2019 +0100
+++ b/src/reportlab/platypus/doctemplate.py	Thu Sep 26 13:44:55 2019 +0100
@@ -981,6 +981,7 @@
                             artBox = self.artBox,
                             trimBox = self.trimBox,
                             bleedBox = self.bleedBox,
+                            lang = self.lang,
                             )
 
         getattr(canv,'setEncrypt',lambda x: None)(self.encrypt)
@@ -994,8 +995,6 @@
         canv.setKeywords(self.keywords)
         if self.displayDocTitle is not None:
             canv.setViewerPreference('DisplayDocTitle',['false','true'][self.displayDocTitle])
-        if self.lang:
-            canv.setCatalogEntry('Lang',self.lang)
 
         if self._onPage:
             canv.setPageCallBack(self._onPage)
--- a/src/reportlab/rl_settings.py	Thu Sep 26 12:24:13 2019 +0100
+++ b/src/reportlab/rl_settings.py	Thu Sep 26 13:44:55 2019 +0100
@@ -63,7 +63,8 @@
 uriWasteReduce
 embeddedHyphenation
 hyphenationMinWordLength
-reserveTTFNotdef'''.split())
+reserveTTFNotdef
+documentLang'''.split())
 
 allowTableBoundsErrors =    1 # set to 0 to die on too large elements in tables in debug (recommend 1 for production use)
 shapeChecking =             1
@@ -150,6 +151,7 @@
 hyphenationMinWordLength=5                          #minimum length of words that can be hyphenated
 reserveTTFNotdef=0                                  #if true force subset element 0 to be zero(.notdef)
                                                     #helps to fix bug in edge
+documentLang=None                                   #pdf document catalog Lang value xx-xx not ee_xx
 
 # places to look for T1Font information
 T1SearchPath =  (