def pdf_serialize(self, stream): raw = codecs.BOM_UTF16_BE + self.encode('utf-16-be') if False: # Disabled as the parentheses based strings give easier to debug # PDF files stream.write(b'<' + as_hex_bytes(raw) + b'>') else: stream.write(b'('+escape_pdf_string(raw)+b')')