weixin_43340596 2020-07-09 13:56 采纳率: 100%
浏览 262

django中使用pdfkit生成pdf

代码是这样写的,123.html页面中有一个通过js加载的表格,最后得到的pdf文件只有html页面的内容,js加载的表格没有出现,怎么才能再pdf中生成js加载的表格呢?

def download(request, report_id):
    retReport = getReport(report_id)
    template = get_template('123.html')
    html = template.render({'retReport': retReport})
    options = {
                    'page-size': 'Letter',
                    'encoding': "utf-8",
                    'javascript-delay': '5000'
            }
    pdf = pdfkit.from_string(html, False, configuration=config, options=options)
    response = HttpResponse(pdf, content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="123.pdf"'
    return response

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-07-09 15:07
    关注

    抓包看看,你的表格ajax方式怎么加载的,找到数据的单独的请求的地址,单独下载解析后生成到pdf里面

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥15 C# datagridview 栏位进度