I will try to give you some points that might be helpful. Now for the pdf, there are so many gotchas, usually if I am not mistaken the idea is to render to HTML to canvas and from there to pdf. But there was already a library that kinda does this so here is the link for that (I am not sure if it is still updated).
As for the csv, the idea is to trigger download on the client side. There are many ways to to this and so many browser gotchas but the main idea revolves around:
create a blob with a proper mime type
create an object URL from that blob
give the object URL to an invisible a tag with download attribute
In older browsers download attribute on a tag is not supported in those cases you can try creating an iframe with the src attribute pointing the the blob url with "application/octet-stream" mime type:
Ibrahim Tanyalcin
{intrst:"Scnc&Art",msc:"admin@MutaFrame",strive:"Experiment&Learn",loves:"ES5",hates:"bandwagon",lang:"Javascript",twttr:"@ibrhmTanyalcin"}
I will try to give you some points that might be helpful. Now for the pdf, there are so many gotchas, usually if I am not mistaken the idea is to render to HTML to canvas and from there to pdf. But there was already a library that kinda does this so here is the link for that (I am not sure if it is still updated).
As for the csv, the idea is to trigger download on the client side. There are many ways to to this and so many browser gotchas but the main idea revolves around:
Here is a mini snippet:
var someObj = [{a:5,b:2},{a:3,b:1}], someCSV = someObj.reduce(function(ac,d,i){return ac+d.a+","+d.b+"\n"},""), someBlob = new Blob([someCSV],{type:"text/plain"}), someURL = window.URL.createObjectURL(someBlob), someAElem = document.createElement("a"); someAElem.href = someURL; someAElem.download = "someCSV.csv"; document.body.appendChild(someAElem).click(); //should trigger download... someBlob = new Blob([someCSV],{type:"application/octet-stream"}), ... iframe = document.createElement("iframe"); iframe.src = someURL; document.body.appendChild(iframe) //should trigger downloadAs always, when you are done don't forget to call URL.revokeObjectURL method when you don't need the Blob URL anymore.
These are just some ideas, there many other implementations out there.