Click here to Skip to main content
11,790,613 members (63,105 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: PDF
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
Edited 26-Jul-12 20:51pm
carechin at 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
0 OriginalGriff 1,154
1 Maciej Los 825
2 KrunalRohit 686
3 ppolymorphe 660
4 CPallini 621

Advertise | Privacy | Mobile
Web02 | 2.8.1509028.1 | Last Updated 8 Jul 2014
Copyright © CodeProject, 1999-2015
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