From 434835738e506a2557b6939de11a61263a251c19 Mon Sep 17 00:00:00 2001 From: Averell7 Date: Sat, 18 Jun 2011 09:13:47 -0700 Subject: [PATCH] Edited writeToStream for poppler compatibility --- pyPdf/generic.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pyPdf/generic.py b/pyPdf/generic.py index aaf5031..8d33591 100644 --- a/pyPdf/generic.py +++ b/pyPdf/generic.py @@ -404,13 +404,16 @@ def writeToStream(self, stream, encryption_key): obj = ByteStringObject(bytearr) obj.writeToStream(stream, None) else: - stream.write("(") - for c in bytearr: - if not c.isalnum() and c != ' ': - stream.write("\\%03o" % ord(c)) - else: - stream.write(c) - stream.write(")") + if bytearr == "/Page" : # correction by Dysmas : otherwise writes (\057Page) instead of /Page, which is valid but not supported by poppler + stream.write(bytearr) + else : + stream.write("(") + for c in bytearr: + if not c.isalnum() and c != ' ': + stream.write("\\%03o" % ord(c)) + else: + stream.write(c) + stream.write(")") class NameObject(str, PdfObject): @@ -797,4 +800,3 @@ def decode_pdfdocencoding(byte_array): continue assert char not in _pdfDocEncoding_rev _pdfDocEncoding_rev[char] = i -