Skip to content

Commit 440596e

Browse files
[FIX] look for 'Done' in stderr
Sometimes wkhtmltopdf will exit with non-zero even if the generation is successful.
1 parent ba42969 commit 440596e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pdfkit/pdfkit.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ def handle_error(exit_code, stderr):
130130
if exit_code == 0:
131131
return
132132

133+
# Sometimes wkhtmltopdf will exit with non-zero
134+
# even if it finishes generation.
135+
# If will display 'Done' in the second last line
136+
if stderr.splitlines()[-2].strip() == 'Done':
137+
return
138+
133139
if 'cannot connect to X server' in stderr:
134140
raise IOError('%s\n'
135141
'You will need to run wkhtmltopdf within a "virtual" X server.\n'

0 commit comments

Comments
 (0)