javascripthtmlinternet-explorerprintingobject-tag

Issue with window.print() in IE9 for a remote file


I have a HTML which has an SVG file embedded in an object tag.

This file is accessed from a shared remote location through file protocol and accessed on IE (IE9 or latest).

I have made changes to trigger window.print() when the key 'P' is pressed and also can do ctrl + P which would show the print dialog.

I have observed that the quality of print differs drastically in both these cases for the above scenario (file accessed remotely on IE9).

We can check by printing to a PDF.

Can anyone explain what is the difference between the two and what should i be doing to make window.print() work the same way it does when we do ctrl + P?

    <!-- DOCTYPE HTML -->
<HTML>
<HEAD><TITLE>Print</TITLE>
<META content="text/html; charset=UTF-8" http-equiv=Content-Type>
<SCRIPT type=text/javascript src="jquery.js"></SCRIPT>
<SCRIPT type=text/javascript>
        function printProcess() {
        jQuery(document).bind("keyup", function(e){    
                if(e.keyCode == 80){
                    p();
                }
            });
        }       
        function p(){
        window.print();
        }
    </SCRIPT>
</HEAD>
<BODY style="WIDTH: 100%;HEIGHT: 100%" onload="printProcess();" >
    <DIV style="HEIGHT: 100%" id="printableDiv" >
        <OBJECT data="test.svg" width="100%" type="image/svg+xml" height="100%">
        </OBJECT>
    </DIV>
</BODY>
</HTML>

Solution

  • For the ppl who are interested, here is the answer. The problem is solved by adding

    <META http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
    

    to the HTML, thanks to Vitor Canova