Click here to Skip to main content
13,046,499 members (72,788 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to print PDF which is present in iframe?

I want to print pdf present in iframe.
I am able to print with browsers IE and Chrome, but it is giving problems with FireFox, Safari and Opera.

I have tried as follows:
function printIframe() {
        if (navigator.userAgent.indexOf("Firefox") != -1) {
//This is not working
            var frame_window = window.frames["my_iframe"];
        else if (navigator.userAgent.indexOf("MSIE") != -1) {
            var x = document.getElementById("pdfDocument");
        else if (navigator.userAgent.indexOf("Chrome") != -1) {
        else {
//not working
            // Safari browser or other one   
//            document.getElementById('my_iframe').focus();
//            document.getElementById('my_iframe').onload = setTimeout('iframe.print()',2500);
//            var ifWin = document.getElementById('my_iframe').contentWindow;
//            ifWin.focus();
//            ifWin.print();

Please guide me for this.

Posted 26-Jul-12 20:24pm
Updated 26-Jul-12 20:51pm
carechin 8-Jul-14 1:30am
May I know how your IE working?
What is your component for "pdfDocument" ?
I have trouble on IE frame as well. Please help.


1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

This solution is for Java, but the principle should be possible to apply.

It addresses Safari and Chrome.[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 8 Jul 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100