added console script

master
Ugo Finnendahl 5 years ago
parent 18b9ea0aef
commit 8fa0aa37e2
  1. 8
      README.md
  2. 2
      html_to_pdf/__init__.py
  3. 11
      html_to_pdf/render.py
  4. 5
      setup.py

@ -8,6 +8,8 @@ pip install git+https://git.finnendahl.de/Yugon/html_to_pdf.git
## API
In python :
```python
import html_to_pdf as h2p
@ -15,3 +17,9 @@ h2p.render_from_url("http://example.com", "out.pdf")
h2p.render_from_file("local_file.html", "out2.pdf")
h2p.render_from_string("<h1>Works</h1>", "out3.pdf")
```
As console script
```bash
html_to_pdf <input> -o <output>
```

@ -1 +1 @@
from .render import render_from_url, render_from_string, render_from_file
from .render import main,render_from_url, render_from_string, render_from_file

@ -39,3 +39,14 @@ def render_from_string(s, out=None):
temp.flush()
render_from_file(temp.name, out=out)
temp.close()
def main():
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("input", help="Input HTML file.")
parser.add_argument("-o", "--output", help="Output filename.", default="out.pdf")
args = parser.parse_args()
render_from_file(args.input, args.output)
print(f"{args.input} rendered into {args.output}")

@ -16,5 +16,8 @@ setuptools.setup(
long_description_content_type="text/markdown",
url="git.finnendahl.de",
packages=setuptools.find_packages(),
include_package_data=True
include_package_data=True,
entry_points={
'console_scripts': ['html_to_pdf=html_to_pdf:main']
}
)

Loading…
Cancel
Save