11pydf
22====
33
4- PDF generation in python using [ wkhtmltopdf] ( http://wkhtmltopdf.org/ ) suitable for Heroku.
4+ PDF generation in python using [ wkhtmltopdf] ( http://wkhtmltopdf.org/ ) .
5+
6+ Wkhtmltopdf binaries are precompiled and included in the package making pydf easier to use,
7+ in particular this means pydf works on heroku.
58
69Based on [ pywkher] ( https://github.com/jwmayfield/pywkher ) but significantly extended.
710
811Currently using ** wkhtmltopdf v. 0.12.2** (beta).
912
13+ ## Install
14+
15+ pip install python-pdf
16+
17+ (pydf was taken, but I guess python-pdf is a clearer name anyway.)
18+
1019## Basic Usage
1120
12- import pydf
13- pdf = pydf.generate_pdf('<h1>this is html</h1>')
14- open('test_doc.pdf', 'w').write(pdf)
21+ ``` python
22+ import pydf
23+ pdf = pydf.generate_pdf(' <h1>this is html</h1>' )
24+ open (' test_doc.pdf' , ' w' ).write(pdf)
1525
16- pdf = pydf.generate_pdf('www.google.com')
17- open('google.pdf', 'w').write(pdf)
26+ pdf = pydf.generate_pdf(' www.google.com' )
27+ open (' google.pdf' , ' w' ).write(pdf)
28+ ```
1829
1930## API
2031
@@ -36,21 +47,21 @@ and None arguments are missed, everything else is passed with str(value).
3647
3748** Arguments:**
3849
39- * source: html string to generate pdf from or url to get
40- * quiet: bool
41- * grayscale: bool
42- * lowquality: bool
43- * margin_bottom: string eg. 10mm
44- * margin_left: string eg. 10mm
45- * margin_right: string eg. 10mm
46- * margin_top: string eg. 10mm
47- * orientation: Portrait or Landscape
48- * page_height: string eg. 10mm
49- * page_width: string eg. 10mm
50- * page_size: string: A4, Letter, etc.
51- * image_dpi: int default 600
52- * image_quality: int default 94
53- * extra_kwargs: any exotic extra options for wkhtmltopdf
50+ * ` source ` : html string to generate pdf from or url to get
51+ * ` quiet ` : bool
52+ * ` grayscale ` : bool
53+ * ` lowquality ` : bool
54+ * ` margin_bottom ` : string eg. 10mm
55+ * ` margin_left ` : string eg. 10mm
56+ * ` margin_right ` : string eg. 10mm
57+ * ` margin_top ` : string eg. 10mm
58+ * ` orientation ` : Portrait or Landscape
59+ * ` page_height ` : string eg. 10mm
60+ * ` page_width ` : string eg. 10mm
61+ * ` page_size ` : string: A4, Letter, etc.
62+ * ` image_dpi ` : int default 600
63+ * ` image_quality ` : int default 94
64+ * ` extra_kwargs ` : any exotic extra options for wkhtmltopdf
5465
5566Returns string representing pdf
5667
@@ -68,6 +79,6 @@ uses -h command line option
6879get extended help string from wkhtmltopdf binary
6980uses -H command line option
7081
71- ### execute_wk(* args)
82+ #### execute_wk(* args)
7283
7384Low level function to call wkhtmltopdf, arguments are added to wkhtmltopdf binary and passed to subprocess with not processing.
0 commit comments