1

I am using ASP.Net MVC5. I need to create a PDF of a View which contains a c3.js chart.

As the chart is rendered an created through javascript (it creates an svg).

I tried to get the View output mentioned in: Render a view as a string

But I just get the initial HTML of the View with the CSS styling. I need the javascript to be executed before creating the PDF.

Please let me know if anybody has faced such a situation.

Or it also would be helpful to suggest any javascript library where I can get a specific as a pdf (without a server trip).

Thanks.

Community
  • 1
  • 1
Virus
  • 2,445
  • 1
  • 14
  • 17
  • I'm sorry, I don't think that's possible. The browser executes your javascript and the browser is the bit you're bypassing by rendering to a string. You could maybe put a button on your generated (rendered as a View) view offering a PDF and create the PDF as described here? - http://www.techumber.com/2015/04/html-to-pdf-conversion-using-javascript.html – Rich Bryant Sep 17 '15 at 16:58
  • @RichBryant Thanks for the response buddy... I have a doubt though... For the CSS also its the browser who applies the styles, how come that part works here? Also, I will sure give a try to your suggestion. Thanks a lot. – Virus Sep 17 '15 at 17:48
  • Granted, but your javascript is usually triggered on document.ready and when rendered to a string, that event doesn't occur. – Rich Bryant Sep 18 '15 at 09:57
  • 1
    @RichBryant Thanks, I tried your solution, but that didn't fit much in my environment... However I found another workaround and used the .Net chart library for generating the chart, which can generate an image which is then included in the View using an . – Virus Sep 21 '15 at 09:37

0 Answers0