Not allowed to navigate top frame to data URL: JsPDF

Viewed 11167
try {
    var a;
    var b = new jsPDF("p", "pt", "a3");
    var c = document.getElementById("leftPieCanvas").toDataURL("image/png");
    b.addImage(c, "PNG", 265, 60);
    a = document.getElementById("rightPieCanvas").toDataURL("image/png");
    b.addImage(a, "PNG", 205, 440);
    if ($("#sales_table").length) {
        var d = tableToJson($("#sales_table").get(0));
        b.setFont("helvetica");
        b.setFontType("bold");
        b.setFontSize(9);
        $.each(d, function(a, c) {
            $.each(c, function(c, d) {
                b.cell(40, 830, 55, 20, d, a);
            });
        });
    }
    b.output("dataurlnewwindow");
} catch (e) {
    alert(e);
}

Above code is working in firefox but not in chrome, i googled and got suggestions that use iframe so i have created iframe but unable to put this code in above code, anyone can suggest please that how do i add the below code into above code so i can render a PDF in google chrome also.

var html = '<html>' +
      '<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}  </style>' +
      '<body>' +
      '<iframe src="' + url + '"></iframe>' +
      '</body></html>';
3 Answers
Related