Created
October 15, 2014 07:14
-
-
Save anonymous/47debcdf06de30f1b7e7 to your computer and use it in GitHub Desktop.
Pasted from IPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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