简体   繁体   English

如何从具有JavaScript内容的网站使用wkhtmltopdf生成pdf

[英]How to generate a pdf with wkhtmltopdf from web site with javascript content

I want to make a script that generates a pdf from a web site every day. 我想制作一个每天从网站生成pdf的脚本。 I'm using wkhtmltopdf 0.12.2.1 (newst version) to generate pdf's. 我正在使用wkhtmltopdf 0.12.2.1(最新版本)来生成pdf。 But the problem is that the table in the website I'm trying to get pdf from is made with javascript. 但是问题是我试图从中获取pdf的网站中的表格是用javascript制作的。 So when I generate the pdf I get only the header of the web site. 因此,当我生成pdf时,我只会得到网站的标题。

Example: 例:

Web site: http://statistika.eestipank.ee/?lng=et#listMenu/981/treeMenu/FINANTSSEKTOR/147/979 网站: http : //statistika.eestipank.ee/?lng=et#listMenu/981/treeMenu/FINANTSSEKTOR/147/979

Command I'm running in console: 命令我在控制台中运行:

wkhtmltopdf http://statistika.eestipank.ee/?lng=et#listMenu/981/treeMenu/FINANTSSEKTOR/147/979 test.pdf

Gives me only this: 仅给我这个: pdf格式

I have searched for solutions and tried already wkhtmltopdf flags: 我已经搜索了解决方案并尝试了wkhtmltopdf标志:

  • --javascript delay 10000 --javascript延迟10000
  • --no-stop-slow-scripts --no-stop-slow-scripts
  • --javascript-enable --javascript-启用

Maybe someone can suggest me an alternative. 也许有人可以建议我替代。

We have used wkhtmltopdf for various projects here at work, but it doesn't do well with pages like this (or pages with a lot of AJAX). 我们已经在工作中将wkhtmltopdf用于各种项目,但是对于这样的页面(或具有很多AJAX的页面),效果并不理想。 I don't have a solution for you to get that working, but you might try an alternative method: Maybe generate the page and save the section of HTML code after it generated and then send that to wkhtmltopdf instead of using the URL? 我没有解决该问题的解决方案,但是您可以尝试另一种方法:也许生成页面并在生成HTML代码后保存该部分,然后将其发送到wkhtmltopdf而不使用URL?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM