I'm new in xhtml2pdf with python , write html code with python in readable format is somehow cumbersome . I want to know how to include .html file in pisa document.Here is simple code in which I create pdf file:
from xhtml2pdf import pisa
def main():
filename = "simplePrint.pdf"
# generate content
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"
pdf = pisa.CreatePDF(xhtml, file(filename, "w"))
if __name__ == "__main__":
main()
If code of html is too large I want to make an another module, place it in myHtml.html file and include in 3rd last line like:
pdf = pisa.CreatePDF(myHtml.html, file(filename, "w"))
How I reach this problem?