Click here to Skip to main content
15,881,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I use the following code to print a MS Chart from my web app. It works great with IE (10 down) and Firefox, but not with Google Chrome Opera & Safari.

C#
function PrintChart() {
    try {
        var thisHTML;
        if (chartToPrint == 1) {
            thisHTML = $("#td_Chart1").html();
        }
        else if (chartToPrint == 2) {
            thisHTML = $("#td_Chart2").html();
        }
        var endPos = thisHTML.indexOf('>');
        var str1 = thisHTML.substring(0, endPos);
        var startPos = str1.indexOf('src');
        endPos = str1.indexOf(' ', startPos);
        var chartsrc = str1.substring(startPos, endPos);
        var printWindow = window.open("Print Chart", "mywindow", "location=1,status=1,scrollbars=1,fullscreen=yes");
        printWindow.document.write("<div style='width:100%;'>");
        printWindow.document.write("<img id='img' " + chartsrc + "/>");
        printWindow.document.write("</div>");
        printWindow.document.close();
        printWindow.print();
        printWindow.close();
    } catch (e) {
        alert(e);
    }
}


Does any one have any suggestions on how to print in Chrome, Opera and Safari.
And please, only valid suggestions, if you are guessing I would rather not hear from you.

And I did find this code on Code Project, so thanks to whom ever posted it in the first place(Sorry don't recall name)

Many Thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900