Skip to content

Instantly share code, notes, and snippets.

@arcolife
Forked from anonymous/file1.py
Last active August 29, 2015 14:07
Show Gist options
  • Save arcolife/02a1bef101ef6f665000 to your computer and use it in GitHub Desktop.
Save arcolife/02a1bef101ef6f665000 to your computer and use it in GitHub Desktop.
xhtml = "<h1 align='center'>Test print</h1>\n"
xhtml += "<h2>This is printed from within a Python application</h2>\n"
xhtml += "<p style=\"color:red;\">Coloured red using css</p>\n"
xhtml
from xhtml2pdf import pisa
ls
filename = "simplePrint.pdf"
pdf = pisa.CreatePDF(xhtml, file(filename, "w"))
ls
pdf = pisa.CreatePDF(xhtml.encode('utf-8, file(filename, "w"))
pdf = pisa.CreatePDF(xhtml.encode('utf-8'), file(filename, "w"))
from StringIO import StringIO
output = StringIO()
pdf = pisa.CreatePDF(xhtml.encode('utf-8'), output)
output.getvalue()
%pastebin 1-16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment