简体   繁体   中英

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. I'm using wkhtmltopdf 0.12.2.1 (newst version) to generate pdf's. But the problem is that the table in the website I'm trying to get pdf from is made with javascript. So when I generate the pdf I get only the header of the web site.

Example:

Web site: 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:

  • --javascript delay 10000
  • --no-stop-slow-scripts
  • --javascript-enable

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). 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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