File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -98,18 +98,18 @@ def to_pdf(self, path=None):
98
98
if self .source .isString () or (self .source .isFile () and self .css ):
99
99
input = self .source .to_s ().encode ('utf-8' )
100
100
elif self .source .isFileObj ():
101
- input = self .source .source .read ()
101
+ input = self .source .source .read (). encode ( 'utf-8' )
102
102
else :
103
103
input = None
104
104
stdout , stderr = result .communicate (input = input )
105
105
106
- if 'Error' in stderr :
107
- raise IOError ('wkhtmltopdf reported an error:\n ' + stderr )
106
+ if 'Error' in stderr . decode ( 'utf-8' ) :
107
+ raise IOError ('wkhtmltopdf reported an error:\n ' + stderr . decode ( 'utf-8' ) )
108
108
109
109
# Since wkhtmltopdf sends its output to stderr we will capture it
110
110
# and properly send to stdout
111
111
if '--quiet' not in args :
112
- sys .stdout .write (stderr )
112
+ sys .stdout .write (stderr . decode ( 'utf-8' ) )
113
113
114
114
if not path :
115
115
return stdout
Original file line number Diff line number Diff line change @@ -272,7 +272,7 @@ def test_pdf_generation_from_file_like(self):
272
272
with open ('fixtures/example.html' , 'r' ) as f :
273
273
r = pdfkit .PDFKit (f , 'file' )
274
274
output = r .to_pdf ()
275
- self .assertEqual (output [:4 ], '%PDF' )
275
+ self .assertEqual (output [:4 ]. decode ( 'utf-8' ) , '%PDF' )
276
276
277
277
def test_raise_error_with_wrong_css_path (self ):
278
278
css = 'fixtures/wrongpath.css'
You can’t perform that action at this time.
0 commit comments