所以我有一个类似Django的视图:
当在浏览器中查看时。但是当PDFKit呈现它时,它看起来就像
请注意,卡的底部不平-这是问题所在。
对于不知道h-100班级的人来说,像这样:
.h-100 { height: 100%!important; }
用于生成PDF的代码为:
def invoice_download(request, invoice_id):
try:
#Get the invoice and render it as a string.
invoice = BusinessInvoice.objects.get(pk=invoice_id)
padcount = [None] * int(8 - invoice.businessinvoiceitem_set.count())
context = {'invoice': invoice, 'padcount': padcount, 'site_url':settings.SITE_URL }
html = render_to_string('business/invoice_print.html', context, request)
#Build the filename
the_date = invoice.date.strftime('%Y-%m-%d')
filename = "INV%03d-%s-%s.pdf" % (invoice.id, invoice.client, the_date)
filename = "".join(filename.split())
fullFilePath = settings.MEDIA_ROOT + 'invoices/' + filename
#Make the pdf and save to fullFilePath
pdfkit.from_string(html, fullFilePath)
#Return the PDF as a file to Django/View
response = FileResponse(open(fullFilePath, 'rb'))
except BusinessInvoice.DoesNotExist:
raise Http404("Something went wrong?")
return response
这是我可以克服的东西,还是我将失去卡的边界?