Skip to content

Commit bc7e71d

Browse files
committed
Normalize Boolean argument values in options to empty string
Fixes #169
1 parent 50d8637 commit bc7e71d

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

pdfkit/pdfkit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ def _normalize_options(self, options):
238238
for optval in value:
239239
yield (normalized_key, optval)
240240
else:
241-
yield (normalized_key, unicode(value) if value else value)
241+
normalized_value = '' if isinstance(value,bool) else value
242+
yield (normalized_key, unicode(normalized_value) if value else value)
242243

243244
def _normalize_arg(self, arg):
244245
return arg.lower()

tests/pdfkit-tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,5 +446,16 @@ def test_issue_140_empty_cookie_value(self):
446446

447447
self.assertEqual(output2[:4].decode('utf-8'), '%PDF')
448448

449+
def test_issue_169_quiet_boolean_True(self):
450+
options = {
451+
'outline': '',
452+
'footer-line': None,
453+
'quiet': True
454+
}
455+
456+
r = pdfkit.PDFKit('html', 'string', options=options)
457+
output = r.to_pdf()
458+
self.assertEqual(output[:4].decode('utf-8'), '%PDF')
459+
449460
if __name__ == "__main__":
450461
unittest.main()

0 commit comments

Comments
 (0)