我有一个任务,使用动态数据呈现HTML页面并将其转换为PDF,但是,实现它时遇到问题。如何呈现HTML Django页面为PDF?
def makepdf(request):
if request.POST:
chatvs = Competirors.objects.get(id = int(request.POST.get('competitor', '')))
jivo_staff = Manager.objects.get(id = int(request.POST.get('manager', '')))
business = Field.objects.get(id = int(request.POST.get('filed', '')))
business = business.link.all().order_by('?')[0:3]
context = {
"chatvs" : chatvs,
"jivo_staff" : jivo_staff,
"business" : business,
}
tmpl = get_template('marketing/jivopdf.html',)
html = tmpl.render(context)
# and i have a problem there with pdfkit
我正在使用Pdfcrowd API,但它削减了所有的CSS样式,看起来不太好。至于vvwkhtmltopdf/pdfkit - 我不知道如何使它成为一个呈现的HTML页面,因为它只访问url/file/string。
有没有办法呈现准备好的HTML页面?