1

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 anything.

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

Community
  • 1
  • 1
don
  • 820
  • 1
  • 6
  • 10

1 Answers1

1

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.

Adam
  • 5,045
  • 1
  • 25
  • 31
  • This helped with a problem I had with partially-rendering graphs, but I've given up on the problem as a whole. Something in wkhtmltopdf's webkit is choking during javascript loading and I can't figure it out. – don Mar 03 '11 at 13:08