-
-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
120 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ Contents | |
:maxdepth: 2 | ||
|
||
reference | ||
reference/cli | ||
|
||
.. toctree:: | ||
:caption: Contributing | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
====================== | ||
Command-line interface | ||
====================== | ||
|
||
.. hint:: At any time, run ``xhtml2pdf --help`` to get help. | ||
|
||
|
||
Basic usage | ||
----------- | ||
|
||
To generate a PDF document from an HTML file called ``source.html`` call: | ||
|
||
.. code:: shell | ||
xhtml2pdf source.html # will create source.pdf | ||
Source | ||
^^^^^^ | ||
|
||
The first positional argument to the CLI should be the source HTML file. | ||
If you want to read it from stdin, you can use ``-``: | ||
|
||
.. code:: shell | ||
some-script-that-outputs-html | xhtml2pdf - output.pdf | ||
You may also supply a webpage using its URL. Don't forget to quote it, when | ||
needed: | ||
|
||
.. code:: shell | ||
xhtml2pdf "https://en.wikipedia.org/w/index.php?title=PDF&oldid=1183757701" output.pdf | ||
Destination | ||
^^^^^^^^^^^ | ||
|
||
The second positional argument is the name of the destination PDF document. If | ||
omitted, xhtml2pdf will pick a name for it. Just like with the source, you can | ||
use ``-`` to redirect the PDF file to stdout. This is particularly useful | ||
together with ``curl`` or GhostScript. | ||
|
||
.. important:: Take care that the destination file is not already opened by | ||
another application (like Acrobat Reader) | ||
|
||
|
||
Options | ||
------- | ||
|
||
Input | ||
^^^^^ | ||
|
||
``--base``/``-b`` | ||
Specify a base path. You should set this when the source HTML is supplied via | ||
stdin, as there is no other way to resolve relative hyperlinks. | ||
|
||
``--encoding`` | ||
The character encoding of the source HTML file. If left empty, this will be | ||
inferred from the HTML ``<meta charset>`` value. | ||
|
||
``--html`` | ||
Parse the source document as HTML (default). | ||
|
||
``--xml``/``--xhtml``/``-x`` | ||
Parse the source document as XHTML. This is set automatically if the source file | ||
name ends with ".xml" | ||
|
||
HTTP Options | ||
"""""""""""" | ||
|
||
These are used when the source is a webpage. | ||
|
||
``--http_nosslcheck`` | ||
Do not check the website's SSL certificate. | ||
|
||
``--http_timeout`` | ||
equivalent to ``timeout`` in :py:class:`http.client.HTTPSConnection` | ||
|
||
``--http_source_address`` | ||
equivalent to ``source_address`` in :py:class:`http.client.HTTPSConnection` | ||
|
||
``--http_key_file`` and ``--http_cert_file`` were removed in Python 3.12 and are | ||
not used anymore. | ||
|
||
Styling | ||
^^^^^^^ | ||
|
||
``--css``/``-c`` | ||
Path to default CSS file. It will be applied to the generated document. If | ||
omitted, a reasonable default will be used. | ||
|
||
``--css-dump`` | ||
Output default CSS file. | ||
|
||
When generating the HTML output, ``xhtml2pdf`` uses an internal default CSS | ||
definition (otherwise all tags would look the same). To get an impression of | ||
what it looks like, run: | ||
|
||
.. code:: shell | ||
xhtml2pdf --css-dump > xhtml2pdf-default.css | ||
Output | ||
^^^^^^ | ||
|
||
``--start-viewer``/``-s`` | ||
Start the default PDF viewer after conversion. | ||
|
||
``--quiet``/``-q`` | ||
Show no messages. | ||
|
||
``--warn``/``-w`` | ||
Show warnings. | ||
|
||
``--debug``/``-d`` | ||
Show debugging information. |