开发者

Generating a PDF from a Tomcat-served webpage

I'm having issues trying to figure out how to generate on server side a PDF from a javascript-heavy webpage that is served from Tomcat (the application is Pentaho CE). The content is a dashboard that responds to user interaction. Pentaho (the application) replaces divs dynamically with various content through AJAX calls. I'd like to export to pdf whatever state the user has the dashboard at. There are no restrictions on what I can put on the server, but I need to avoid having the client install anythi开发者_高级运维ng.

I've taken a look at this, along with a bunch of other google-fu: JSP/HTML Page to PDF conversion

wkhtmltopdf seems to be a popular choice; before I start banging my head against it, I have a few questions:

  • Can wkhtmltopdf handle going to password protected jsps where authentication is handled by the application? Would the dynamically loaded divs break it?
  • Is there a way to perhaps return the client view to the server for processing? I read about screen capturing...
  • Another option that could work out would be to automate a local access to the dashboard on the server through a server-hosted web browser and generate a PDF that way...is this possible, given the constraints of Tomcat and password protection that's handled by the application? The javascript components that Pentaho generates cannot be accessed outside of the application.

Thanks!

EDIT:

Good news! wkhtmltopdf works! Kind of. I got past the password authentication through putting the login details through a query string, and I'm getting a pdf of the correct page now. The issue is that no javascript components are showing up... (they work for pages like yahoo.com, so maybe I'm missing something here).


If you have a lot of AJAX calls you should wait for them. Use the --javascript-delay x argument, where is x is the time to wait.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜