django html导出pdf,如何在django中将动态html页面转换为pdf?

1)我解析一些页面来获取信息。 2)由于它的信息很难分离,所以我把它安装到html页面,并使其与自定义CSS美丽。 3)然后我尝试将其转换为pdf,以提供给客户。如何在django中将动态html页面转换为pdf?

但是所有pdf对流式转换器都要求特定的url或文件等。例如:

def parse(request):

done = csrf(request)

if request.POST:

USERNAME = request.POST.get('logins', '')

PASSWORD = request.POST.get('password', '')

dialogue_url = request.POST.get('links', '')

total_pages = int(request.POST.get('numbers', ''))

news = []

news.extend(parse_one(USERNAME, PASSWORD, dialogue_url, total_pages))

contex = {

"news" : news,

}

done.update(contex)

pageclan = render(request, 'marketing/parser.html', done)

# create an API client instance

client = pdfcrowd.Client(*** ***)

# convert a web page and store the generated PDF to a variable. That is doesn't work. Convertor doesn't support such url.

pdf = client.convertURI('pageclan')

# set HTTP response headers

response = HttpResponse(content_type="application/pdf")

response["Cache-Control"] = "max-age=0"

response["Accept-Ranges"] = "none"

response["Content-Disposition"] = "attachment; filename=jivo_log.pdf"

# send the generated PDF

response.write(pdf)

return response

有什么工具可以正常工作吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值