attempt to fix up the catalog language setting feature-accessibility
authorrobin
Thu, 26 Sep 2019 13:43:11 +0100
branchfeature-accessibility
changeset 4529 0e81d462d3b9
parent 4527 4ad8bc793866
child 4530 3f6cc4ae6211
child 4532 e077a9f6cb99
attempt to fix up the catalog language setting
src/reportlab/pdfbase/pdfdoc.py
src/reportlab/platypus/doctemplate.py
src/reportlab/rl_settings.py
--- a/src/reportlab/pdfbase/pdfdoc.py	Tue Sep 24 12:38:18 2019 +0100
+++ b/src/reportlab/pdfbase/pdfdoc.py	Thu Sep 26 13:43:11 2019 +0100
@@ -138,7 +138,6 @@
         self.shadingCounter = 0
         self.inObject = None
         self.pageCounter = 1
-        self.lang = lang
 
         # allow None value to be passed in to mean 'give system defaults'
         if invariant is None:
@@ -165,7 +164,7 @@
         cat = self.Catalog = self._catalog = PDFCatalog()
         pages = self.Pages = PDFPages()
         cat.Pages = pages
-        cat.lang = self.lang
+        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/platypus/doctemplate.py	Tue Sep 24 12:38:18 2019 +0100
+++ b/src/reportlab/platypus/doctemplate.py	Thu Sep 26 13:43:11 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	Tue Sep 24 12:38:18 2019 +0100
+++ b/src/reportlab/rl_settings.py	Thu Sep 26 13:43:11 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 =  (