src/reportlab/pdfbase/pdfdoc.py
branchpy33
changeset 3781 df8b57380768
parent 3747 7155d7117e67
child 3794 398ea04239b5
--- a/src/reportlab/pdfbase/pdfdoc.py	Tue Oct 15 14:45:50 2013 +0100
+++ b/src/reportlab/pdfbase/pdfdoc.py	Tue Oct 15 14:53:40 2013 +0100
@@ -18,7 +18,8 @@
 from reportlab.pdfbase import pdfutils
 from reportlab.pdfbase.pdfutils import LINEEND # this constant needed in both
 from reportlab import rl_config
-from reportlab.lib.utils import import_zlib, open_for_read, fp_str, makeFileName, isSeq, isBytes, isUnicode, _digester
+from reportlab.lib.utils import import_zlib, open_for_read, makeFileName, isSeq, isBytes, isUnicode, _digester
+from reportlab.lib.rl_accel import escapePDF, fp_str, asciiBase85Encode, asciiBase85Decode
 from reportlab.pdfbase import pdfmetrics
 from hashlib import md5
 
@@ -635,7 +636,7 @@
             escape = 1
         if escape:
             try:
-                es = "(%s)" % pdfutils._escape(s)
+                es = "(%s)" % escapePDF(s)
             except:
                 raise ValueError("cannot escape %s %s" % (s, repr(s)))
             if escape&2:
@@ -646,7 +647,7 @@
         else:
             return b'(' + s + b')'
     def __str__(self):
-        return "(%s)" % pdfutils._escape(self.s)
+        return "(%s)" % escapePDF(self.s)
 
 def PDFName(data,lo=chr(0x21),hi=chr(0x7e)):
     # might need to change this to class for encryption
@@ -770,14 +771,13 @@
 class PDFStreamFilterBase85Encode:
     pdfname = "ASCII85Decode"
     def encode(self, text):
-        from .pdfutils import _AsciiBase85Encode, _wrap
-        text = _AsciiBase85Encode(text)
+        from .pdfutils import _wrap
+        text = asciiBase85Encode(text)
         if rl_config.wrapA85:
             text = _wrap(text)
         return text
     def decode(self, text):
-        from .pdfutils import _AsciiBase85Decode
-        return _AsciiBase85Decode(text)
+        return asciiBase85Decode(text)
 
 # need only one of these too
 PDFBase85Encode = PDFStreamFilterBase85Encode()
@@ -2196,7 +2196,7 @@
             self._dotrans = 1
         self.streamContent = imageFile.read()
         if rl_config.useA85:
-            self.streamContent = pdfutils._AsciiBase85Encode(self.streamContent)
+            self.streamContent = asciiBase85Encode(self.streamContent)
             self._filters = 'ASCII85Decode','DCTDecode' #'A85','DCT'
         else:
             self._filters = 'DCTDecode', #'DCT'
@@ -2245,7 +2245,7 @@
             #assert len(raw) == self.width*self.height, "Wrong amount of data for image expected %sx%s=%s got %s" % (self.width,self.height,self.width*self.height,len(raw))
             self.streamContent = zlib.compress(raw)
             if rl_config.useA85:
-                self.streamContent = pdfutils._AsciiBase85Encode(self.streamContent)
+                self.streamContent = asciiBase85Encode(self.streamContent)
                 self._filters = 'ASCII85Decode','FlateDecode' #'A85','Fl'
             else:
                 self._filters = 'FlateDecode', #'Fl'