0

How can one copy a particular div contents into pdf?

I have searched it and found only a single solution i.e. jsPdf.

I am currently using it itself, but I do not want this, as it doesn't provides custom stylings for targeting different elements.

Edit 1 The suggested link didn't solved my problem.

Shashank
  • 2,010
  • 2
  • 18
  • 38
  • 2
    [html2canvas](https://html2canvas.hertzen.com/) may be it can be useful . – Rajan Singh Sep 09 '16 at 08:16
  • 1
    possible duplicate of :http://stackoverflow.com/questions/17293135/download-a-div-in-a-html-page-as-pdf-using-javascript , http://stackoverflow.com/questions/18191893/generate-pdf-from-html-in-div-using-javascript – Gogol Sep 09 '16 at 08:20
  • @Gogol, did you actually read the question. The links that you shared, I have already gone through them, and it didn't solved my issue. – Shashank Sep 09 '16 at 09:01
  • I did. You could still make it work without jspsf. See other answers too. Basic idea isto open a popup window, place content in that window, apply whatever styling is needed through js/css fle.. and print that window. Does it not work for you? – Gogol Sep 09 '16 at 09:04
  • @Gogol, that might work, but my application restricts from opening up a new window. – Shashank Sep 09 '16 at 09:08
  • 1
    That's bad. In that case, I would render whatever is needed to be printed, using another url, and use wkhtmltopdf ( google it, it's a program available for both linux and windows) to render the content of that url as a pdf. This whole thing can be done in ajax, so no refresh needed. – Gogol Sep 09 '16 at 09:12
  • @Gogol, although *wkhtmltopdf* is a good option, but what I need is, there is a link in the html page itself - Download, on click of it a particular `div` should get downloaded. I don't think this tool can be included in the existing application, as the management. – Shashank Sep 09 '16 at 10:18

0 Answers0