Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions pyPdf/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -797,4 +800,3 @@ def decode_pdfdocencoding(byte_array):
continue
assert char not in _pdfDocEncoding_rev
_pdfDocEncoding_rev[char] = i