Skip to content

Commit efc461c

Browse files
author
Matheus Marchini
committed
Adding the possibility to pass multiple css files as a parameter
1 parent 78acf23 commit efc461c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pdfkit/pdfkit.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PDFKit(object):
1919
:param options: dict (optional) with wkhtmltopdf options, with or w/o '--'
2020
:param toc: dict (optional) - toc-specific wkhtmltopdf options, with or w/o '--'
2121
:param cover: str (optional) - url/filename with a cover html page
22-
:param css: str (optional) - path to css file which will be added to input string
22+
:param css: str (optional) - path to css file which will be added to input string or a list with multiple paths
2323
:param configuration: (optional) instance of pdfkit.configuration.Configuration()
2424
"""
2525

@@ -161,8 +161,14 @@ def _prepend_css(self, path):
161161
raise self.ImproperSourceError('CSS file can be added only to a single '
162162
'file or string')
163163

164-
with open(path) as f:
165-
css_data = f.read()
164+
if not hasattr(path, "__iter__"):
165+
path = [path]
166+
167+
css_data = ""
168+
for p in path:
169+
with open(p) as f:
170+
css_data += f.read()
171+
css_data += "\n"
166172

167173
if self.source.isFile():
168174
with open(self.source.to_s()) as f:

0 commit comments

Comments
 (0)