3

I'm using xhtmlrenderer + iText in Java to generate PDFs for some pages in my application. I've managed to convert some pages already. However, I came across a limitation to this approach where it can't convert pages dynamically created using JavaScript scripts (some by JQuery). Are there other available tools for this?

Thanks.

Psycho Punch
  • 6,418
  • 9
  • 53
  • 86
  • i've also looked, though i was looking for a python solution. i couldn't find one that supported javascript as far as i remember. – Chris Nov 23 '10 at 21:10
  • If this is something that only needs to be done once, and not dynamically, you might see if your Print dialog has an option for PDF output. – drudge Nov 23 '10 at 21:27
  • One approach might be to use JavaScript to grab the entire DOM after a page is stable, serialize the DOM, and then send it to the server for PDF processing. – tschaible Apr 22 '11 at 12:11

1 Answers1

0

Your best bet is wkhtmltopdf. It's a PDF converter sitting on top of web kit, complete with its JS environment. I haven't tried it myself (yet).

Mark Storer
  • 15,672
  • 3
  • 42
  • 80
  • I'm not really sure if that's what I need. I'm actually doing some sort of a reporting tool for a Web application that can generate PDF versions of the pages. – Psycho Punch Nov 25 '10 at 22:49
  • I'm a committer on iText. I know what it can do, and I know its HTML converter isn't its strong suit. Call wkhtmltopdf via the command line in java. HTML in, PDF out, and it'll handle any and all DOM script you throw its way. What am I missing? – Mark Storer Nov 26 '10 at 06:04
  • Can I do this over Java? As in via a method call? – Psycho Punch Dec 01 '10 at 08:38
  • Runtime.getRuntime().exec(commandLine); Or perhaps some JNI calls. – Mark Storer Dec 01 '10 at 20:56