我刚刚找到wkhtmltopdf,一个使用 webkit 的惊人的 html 转换器。我已经在我的开发机器上尝试过它,它很简单而且效果很好。
这如何最好地与基于 django 的站点集成?
我找到了python bindings,但他们假定对如何安装我没有的东西有一定程度的理解。例如
you need libwkhtmltox.* somewhere in your LD path (/usr/local/lib)
you need the directory src/include/wkhtmltox from wkhtmltopdf
somewhere on your include path (/usr/local/include)
安装这些 python 绑定后,我该如何使用它们?我可以拨打哪些电话?
生成的 pdf 是否必须保存到 hd 或者我可以用什么东西把它从视图中流出来?
例如:
response['Content-Disposition'] = 'attachment; filename='+letter_name
response['Content-Type'] = 'Content-type: application/octet-stream'
response['Content-Length'] = bytes
return response