I am trying to using xhtml2pdf to print webpage into local disk PDF files. There's an example found as below.
It runs and doesn't return error. However it doesn't convert the webpage but only a sentence. in this case, only 'http://www.yahoo.com/' is written into the PDF file.
How can I actually convert the web page into PDF?
from xhtml2pdf import pisa
sourceHtml = 'http://www.yahoo.com/'
outputFilename = "test.pdf"
def convertHtmlToPdf(sourceHtml, outputFilename):
resultFile = open(outputFilename, "w+b")
pisaStatus = pisa.CreatePDF(sourceHtml,resultFile)
resultFile.close()
return pisaStatus.err
if __name__=="__main__":
pisa.showLogging()
convertHtmlToPdf(sourceHtml, outputFilename)