pdf2txt: do not double encode stdout

pull/1/head
cybjit 2014-09-07 18:34:11 +02:00
parent 28c2a4e6ad
commit 0a2d90c051
2 changed files with 5 additions and 1 deletions

View File

@ -164,7 +164,9 @@ class TextConverter(PDFConverter):
return return
def write_text(self, text): def write_text(self, text):
self.outfp.write(text.encode(self.codec, 'ignore')) if self.codec:
text = text.encode(self.codec, 'ignore')
self.outfp.write(text)
return return
def receive_layout(self, ltpage): def receive_layout(self, ltpage):

View File

@ -85,6 +85,8 @@ def main(argv):
outfp = open(outfile, 'wb') outfp = open(outfile, 'wb')
else: else:
outfp = sys.stdout outfp = sys.stdout
if outfp.encoding is not None:
codec = None
if outtype == 'text': if outtype == 'text':
device = TextConverter(rsrcmgr, outfp, codec=codec, laparams=laparams, device = TextConverter(rsrcmgr, outfp, codec=codec, laparams=laparams,
imagewriter=imagewriter) imagewriter=imagewriter)