Skip to content

Instantly share code, notes, and snippets.

@shahidhk
Created December 6, 2013 21:42
Show Gist options
  • Select an option

  • Save shahidhk/7832604 to your computer and use it in GitHub Desktop.

Select an option

Save shahidhk/7832604 to your computer and use it in GitHub Desktop.
import pdfcrowd
try:
# create an API client instance
client = pdfcrowd.Client("username", "apikey")
# convert a web page and store the generated PDF into a pdf variable
pdf = client.convertURI('http://www.google.com')
# convert an HTML string and save the result to a file
output_file = open('html.pdf', 'wb')
html="<head></head><body>My HTML Layout</body>"
client.convertHtml(html, output_file)
output_file.close()
# convert an HTML file
output_file = open('file.pdf', 'wb')
client.convertFile('/path/to/MyLayout.html', output_file)
output_file.close()
except pdfcrowd.Error, why:
print 'Failed:', why
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment