Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am printing my PDF tickets using IFrame and javascript

It is not working in Firefox and IE.
Main page and IFrame in same page.

Here is my code

C#
  <input type="image" value="Print" onclick="printIframe('iFramePdf');" src="/Images/print_red.png" />

<div style="display:none;">
 <iframe id="iFramePdf" src="/Images/Barcode/1b9a73eb-4961-4ce7-88f1-7317b7ca8d97.pdf" style="dispaly:none; visibility:hidden;"></iframe>
</div>



JavaScript
   <script type="text/javascript">
    var width = screen.width;
    var height = screen.height;

    function printIframe(elementId) {
        var getMyFrame = document.getElementById(elementId);
        getMyFrame.focus();
        getMyFrame.contentWindow.print();
    }

</script>
Posted

1 solution

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