javascript - geo chart saving as image or pdf is working in chrome but not in Firefox Browser -
javascript - geo chart saving as image or pdf is working in chrome but not in Firefox Browser -
i'm using next javascript code please 1 tell me improve , possible save whole page pdf? image(image/octet-stream) coming without format *.png or *.jpg please improve code , suggest changes it'll work on firefox well.
function getimgdata(chartcontainer) { var chartarea = chartcontainer.getelementsbytagname('svg')[0].parentnode; var svg = chartarea.innerhtml; var doc = chartcontainer.ownerdocument; var canvas = doc.createelement('canvas'); canvas.setattribute('width', chartarea.offsetwidth); canvas.setattribute('height', chartarea.offsetheight); canvas.setattribute( 'style', 'position: absolute; ' + 'top: ' + (-chartarea.offsetheight * 2) + 'px;' + 'left: ' + (-chartarea.offsetwidth * 2) + 'px;'); doc.body.appendchild(canvas); canvg(canvas, svg); var imgdata = canvas.todataurl("image/png"); canvas.parentnode.removechild(canvas); homecoming imgdata; } function saveasimg(chartcontainer) { var imgdata = getimgdata(chartcontainer); // replacing mime-type forcefulness browser trigger download // rather displaying image in browser window. window.location = imgdata.replace("image/png", "image/octet-stream"); } function toimg(chartcontainer, imgcontainer) { var doc = chartcontainer.ownerdocument; var img = doc.createelement('img'); img.src = getimgdata(chartcontainer); while (imgcontainer.firstchild) { imgcontainer.removechild(imgcontainer.firstchild); } imgcontainer.appendchild(img); }
and 1 more think i'm not using mvc. working on simple vb.net website
javascript pdf html5-canvas google-visualization
Comments
Post a Comment