我有一個任務,使用動態數據呈現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頁面?