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.
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