关于在python2.7中使用html2pdf将html转换为pdf的问题
当我呈现html时,这是正常的,但是当我将其转换为pdf时,请使用pisa:关于在python2.7中使用html2pdf将html转换为pdf的问题,python,html,pdf,html2pdf,pisa,Python,Html,Pdf,Html2pdf,Pisa,当我呈现html时,这是正常的,但是当我将其转换为pdf时,请使用pisa: def render_html2pdf_stream_pisa(template_src, context_dict): template = get_template(template_src) context = Context(context_dict) html = template.render(context) try: result = StringI
def render_html2pdf_stream_pisa(template_src, context_dict):
template = get_template(template_src)
context = Context(context_dict)
html = template.render(context)
try:
result = StringIO.StringIO()
pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")),
dest=result,
encoding="UTF-8",
)
if not pdf.err:
return result.getvalue()
except Exception,e:
print Exception(e)
return None
因此,pdf是半成品,不像html样式那样是完整的pdf文件
我不知道问题出在哪里我用pdfkit解决了问题,但我找不到解决问题的方法使用pisa解决了问题使用pdfkit,但我找不到解决问题的方法使用pisa