Skip to content

Commit 6ad619f

Browse files
committed
Merge branch 'yohanboniface-optional-output-path' into dev
2 parents c18af15 + 81ce7fe commit 6ad619f

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Installation
2828
.. code-block:: bash
2929
3030
$ sudo apt-get install wkhtmltopdf
31-
31+
3232
* macOS:
3333

3434
.. code-block:: bash
@@ -70,8 +70,8 @@ If you wish to further process generated PDF, you can read it to a variable:
7070

7171
.. code-block:: python
7272
73-
# Use False instead of output path to save pdf to a variable
74-
pdf = pdfkit.from_url('http://google.com', False)
73+
# Without output_path, PDF is returned for assigning to a variable
74+
pdf = pdfkit.from_url('http://google.com')
7575
7676
You can specify all wkhtmltopdf `options <http://wkhtmltopdf.org/usage/wkhtmltopdf.txt>`_. You can drop '--' in option name. If option without value, use *None, False* or *''* for dict value:. For repeatable options (incl. allow, cookie, custom-header, post, postfile, run-script, replace) you may use a list or a tuple. With option that need multiple values (e.g. --custom-header Authorization secret) we may use a 2-tuple (see example below).
7777

pdfkit/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from .pdfkit import Configuration
55

66

7-
def from_url(url, output_path, options=None, toc=None, cover=None,
7+
def from_url(url, output_path=None, options=None, toc=None, cover=None,
88
configuration=None, cover_first=False):
99
"""
1010
Convert file of files from URLs to PDF document
1111
1212
:param url: URL or list of URLs to be saved
13-
:param output_path: path to output PDF file. False means file will be returned as string.
13+
:param output_path: (optional) path to output PDF file. By default, PDF will be returned for assigning to a variable.
1414
:param options: (optional) dict with wkhtmltopdf global and page options, with or w/o '--'
1515
:param toc: (optional) dict with toc-specific wkhtmltopdf options, with or w/o '--'
1616
:param cover: (optional) string with url/filename with a cover html page
@@ -26,13 +26,13 @@ def from_url(url, output_path, options=None, toc=None, cover=None,
2626
return r.to_pdf(output_path)
2727

2828

29-
def from_file(input, output_path, options=None, toc=None, cover=None, css=None,
29+
def from_file(input, output_path=None, options=None, toc=None, cover=None, css=None,
3030
configuration=None, cover_first=False):
3131
"""
3232
Convert HTML file or files to PDF document
3333
3434
:param input: path to HTML file or list with paths or file-like object
35-
:param output_path: path to output PDF file. False means file will be returned as string.
35+
:param output_path: (optional) path to output PDF file. By default, PDF will be returned for assigning to a variable.
3636
:param options: (optional) dict with wkhtmltopdf options, with or w/o '--'
3737
:param toc: (optional) dict with toc-specific wkhtmltopdf options, with or w/o '--'
3838
:param cover: (optional) string with url/filename with a cover html page
@@ -49,13 +49,13 @@ def from_file(input, output_path, options=None, toc=None, cover=None, css=None,
4949
return r.to_pdf(output_path)
5050

5151

52-
def from_string(input, output_path, options=None, toc=None, cover=None, css=None,
52+
def from_string(input, output_path=None, options=None, toc=None, cover=None, css=None,
5353
configuration=None, cover_first=False):
5454
"""
5555
Convert given string or strings to PDF document
5656
5757
:param input: string with a desired text. Could be a raw text or a html file
58-
:param output_path: path to output PDF file. False means file will be returned as string.
58+
:param output_path: (optional) path to output PDF file. By default, PDF will be returned for assigning to a variable.
5959
:param options: (optional) dict with wkhtmltopdf options, with or w/o '--'
6060
:param toc: (optional) dict with toc-specific wkhtmltopdf options, with or w/o '--'
6161
:param cover: (optional) string with url/filename with a cover html page

0 commit comments

Comments
 (0)