How to save content of div in pdf or jpg file, which contains GridView and Charts inside it? I have tried using ITextShart, but it is not working for gridview and chart.
Asked
Active
Viewed 279 times
0
-
you don't mean a screenshot (that would include the browser bar and start menu etc etc and is generated by the user pressing PrtScr), you mean how to capture the contents of the page into a PDF. I guess the issue is it isn't incuding images? See https://www.google.co.uk/search?safe=active&q=iTextSharp+include+images&spell=1&sa=X&ved=0ahUKEwjT8o-S6srYAhWBIVAKHeiPAWYQBQgmKAA&biw=1422&bih=982 for suggestions. What did you try so far? Unless these things are done as SVG elements maybe instead? – ADyson Jan 09 '18 at 11:58
-
Instead of "Gridview", you can use the "jQuery DataTable" (is a library available in nuget) which is having default Export options(Excel, csv,pdf,print). Url : https://datatables.net/ – Chandan Kumar Jan 09 '18 at 12:06
-
@ADyson : Not Prntscrn thing , I want everything present in the div to get saved in jpg of pdf file. I have tried using Itextsharp third party tool to export content as pdf . but it is not working for GridView and chart. – satya prakash sharma Jan 09 '18 at 13:01
-
@ChandanKumar : Actually These things are already implemented and now i need to add one more feature of export functionality.So, I cannot change gridview with jquery datatable. – satya prakash sharma Jan 09 '18 at 13:03
-
"Not Prntscrn thing"...I know, that's why I was advising you not to use that phrase, it's meaning doesn't describe the thing you want. Anyway did you look at the suggestions in the link I posted? You should also show your current code, in case there's something obvious you did wrong. – ADyson Jan 09 '18 at 13:54
1 Answers
0
Use jsPDF to generate pdf of your div.
https://github.com/MrRio/jsPDF
var doc = new jsPDF({
//pdf config goes here
})
var myDiv=$('.myDiv').html();
doc.text(myDiv, 1, 1);
doc.save('your_div.pdf');

Iniamudhan
- 478
- 4
- 17
-
Thanks Iniamudhan , This worked . I will search for more details to configure according to my need. Can you share any good links if you know of any? – satya prakash sharma Jan 12 '18 at 09:01