Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,9 @@ lob.Check.create(
memo = 'Services Rendered'
)
```

## Creating a PDF

We recommed using [python-pdfkit](https://github.com/JazzCore/python-pdfkit) to generate PDFs using HTML input. This depends on having [wkhtmltopdf](http://wkhtmltopdf.org/) installed.

You can find an example [here](examples/create_pdf.py)
30 changes: 30 additions & 0 deletions examples/create_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import lob
import pdfkit

lob.api_key = "test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc" # Replace this API key with your own.

body = """
<html>
<body>
<div style="text-align: center; color: blue;" />
<img src="https://www.lob.com/assets/images/printing_icon.png" />
<h1>Print with Lob</h1>
</div>
</body>
</html>
"""

pdfkit.from_string(body, 'out.pdf', {
'page-height': '6.25in',
'page-width': '4.25in',
'quiet': ''
})

example_object = lob.Object.create(
name='Example Object',
file=open('out.pdf', 'rb'),
setting_id=201,
full_bleed=1
)

print "Check out the created PDF here: " + example_object.url