A Simpler python wrapper for wkhtmltopdf, inspired by Qoda's python-wkhtmltopdf
Project description
# wkhtmltopdf-wrapper
A simple and direct python wrapper for the [wkhtmltopdf lib](https://github.com/wkhtmltopdf/wkhtmltopdf)
inspired by inspired by [Qoda's python-wkhtmltopdf](https://github.com/qoda/python-wkhtmltopdf)
## Requirements
### System:
- Linux 32/64 or OSX only (Windows is not supported at this stage)
- wkhtmltopdf
- python 2.5+ / python3
## Installation
### wkhtmltopdf (Linux)
1. Install Fonts:
```bash
$ sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
```
2. Install wkhtmltopdf
goto [http://wkhtmltopdf.org/downloads.html](http://wkhtmltopdf.org/downloads.html) for the latest release (Recommended)
### wkhtmltopdf (OSX)
or goto [http://wkhtmltopdf.org/downloads.html](http://wkhtmltopdf.org/downloads.html) for the latest release (Recommended)
## wkhtmltopdf-wrapper (Any Platform)
1. PIP:
```bash
$ pip install wkhtmltopdf-wrapper
```
or
```bash
$ pip install git+https://github.com/aguegu/wkhtmltopdf-wrapper.git
```
2. Development:
```bash
$ git clone https://github.com/aguegu/wkhtmltopdf-wrapper.git
$ cd wkhtmltopdf-wrapper
$ virtualenv .
$ pip install -r requirements.pip
```
# Usage
the option_string would be sent to the wkhtmltopdf command line in exactly the same shape. so the options can be anything as long as the wkhtmltopdf supports. check its [usage](http://wkhtmltopdf.org/usage/wkhtmltopdf.txt).
This lib is just as simple as that. If anything goes wrong, just check the doc. If the command execute ok with wkhtmltopdf dircetly, this wrapper should work too.
As I check [qoda/python-wkhtmltopdf](https://github.com/qoda/python-wkhtmltopdf), where this repo forked from, it tried to prase args. But it only include a small set of the arguments the command supports. Furthermore, it set default values to this set of arguments and pass them all to the command. For me, it is totally unnecessary and even mistakeful. There is default setting setup and doc in the command. Some arugments may not even work together, as `--page-size` and `--page-height`, `--page-width`. So my solution is just pass the option in as a string, Lazy, flexible and effective.
### from class:
```python
from wkhtmltopdfwrapper import WKHtmlToPdf
wkhtmltopdf = WKHtmlToPdf('-T 20 -B 20 -g --zoom 1.5')
# option_string
wkhtmltopdf.render('http://www.example.com', '~/example.pdf')
# source url, output file path
```
### from method:
```python
from wkhtmltopdfwrapper import wkhtmltopdf
wkhtmltopdf('example.com', '~/example.pdf', '-T 20 -B 20 -g --zoom 1.5')
```
### from commandline (installed):
```bash
$ python -m wkhtmltopdfwrapper.__init__ example.com ~/example.pdf -T 20 -B 20 -g --zoom 1.5
```
Authors:
========
- Jonathan Bydendyk (jpbydendyk@gmail.com)
- Weihong Guan (weihong.guan@gmail.com)
A simple and direct python wrapper for the [wkhtmltopdf lib](https://github.com/wkhtmltopdf/wkhtmltopdf)
inspired by inspired by [Qoda's python-wkhtmltopdf](https://github.com/qoda/python-wkhtmltopdf)
## Requirements
### System:
- Linux 32/64 or OSX only (Windows is not supported at this stage)
- wkhtmltopdf
- python 2.5+ / python3
## Installation
### wkhtmltopdf (Linux)
1. Install Fonts:
```bash
$ sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
```
2. Install wkhtmltopdf
goto [http://wkhtmltopdf.org/downloads.html](http://wkhtmltopdf.org/downloads.html) for the latest release (Recommended)
### wkhtmltopdf (OSX)
or goto [http://wkhtmltopdf.org/downloads.html](http://wkhtmltopdf.org/downloads.html) for the latest release (Recommended)
## wkhtmltopdf-wrapper (Any Platform)
1. PIP:
```bash
$ pip install wkhtmltopdf-wrapper
```
or
```bash
$ pip install git+https://github.com/aguegu/wkhtmltopdf-wrapper.git
```
2. Development:
```bash
$ git clone https://github.com/aguegu/wkhtmltopdf-wrapper.git
$ cd wkhtmltopdf-wrapper
$ virtualenv .
$ pip install -r requirements.pip
```
# Usage
the option_string would be sent to the wkhtmltopdf command line in exactly the same shape. so the options can be anything as long as the wkhtmltopdf supports. check its [usage](http://wkhtmltopdf.org/usage/wkhtmltopdf.txt).
This lib is just as simple as that. If anything goes wrong, just check the doc. If the command execute ok with wkhtmltopdf dircetly, this wrapper should work too.
As I check [qoda/python-wkhtmltopdf](https://github.com/qoda/python-wkhtmltopdf), where this repo forked from, it tried to prase args. But it only include a small set of the arguments the command supports. Furthermore, it set default values to this set of arguments and pass them all to the command. For me, it is totally unnecessary and even mistakeful. There is default setting setup and doc in the command. Some arugments may not even work together, as `--page-size` and `--page-height`, `--page-width`. So my solution is just pass the option in as a string, Lazy, flexible and effective.
### from class:
```python
from wkhtmltopdfwrapper import WKHtmlToPdf
wkhtmltopdf = WKHtmlToPdf('-T 20 -B 20 -g --zoom 1.5')
# option_string
wkhtmltopdf.render('http://www.example.com', '~/example.pdf')
# source url, output file path
```
### from method:
```python
from wkhtmltopdfwrapper import wkhtmltopdf
wkhtmltopdf('example.com', '~/example.pdf', '-T 20 -B 20 -g --zoom 1.5')
```
### from commandline (installed):
```bash
$ python -m wkhtmltopdfwrapper.__init__ example.com ~/example.pdf -T 20 -B 20 -g --zoom 1.5
```
Authors:
========
- Jonathan Bydendyk (jpbydendyk@gmail.com)
- Weihong Guan (weihong.guan@gmail.com)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for wkhtmltopdf-wrapper-0.3.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c44897e1cc2e1fb8a3a6700aaebcfe3a46e908e312f68d3d3cff2abbfc9d3bba |
|
MD5 | 63ddb2a3203cc4325b0e5bc2daff49ef |
|
BLAKE2b-256 | 1816bee61eaa735d10c79068b1bcb36de905c66cdfd4ba9278dd477fe5b372d1 |
Close
Hashes for wkhtmltopdf_wrapper-0.3.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed2ca8f13a92965f180a86d934d7a2564d76e443e0cc2e7996bc26fdefb27c44 |
|
MD5 | 9fdfd03d6ff02bc03f65ea0dea150669 |
|
BLAKE2b-256 | d0916194b645434091a2eda38e74e1677c385798b10b1956805a9c53dd9c2c5f |