PDF in an iframe can't be printed with JavaScript in Firefox 4.




8 years ago
4 years ago


(Reporter: bertilow, Unassigned)


4.0 Branch

Firefox Tracking Flags

(Not tracked)





8 years ago
User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0 FirePHP/0.5
Build Identifier: Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0 FirePHP/0.5

Printing of PDFs inside of iframes with the Javascript command print() does not work in Firefox 4. It used to work in Firefox 3.

Reproducible: Always

Steps to Reproduce:
1. Go to the test page at http://bertilow.com/div/pdftest/index.html
2. Wait for the PDF to load, then click the button "Print the PDF".
3. Nothing happens.
Actual Results:  
Nothing happens.

Expected Results:  
The Firefox print window should open (showing a preview of the PDF).

I have tried using the ordinary Acrobat Reader PDF plugin, and also using mozplugger with Evince. The results are the same: the JavaScript print() function is dead for a PDF inside of an iframe. It is possible to print the entire page, but not the PDF. In Firefox 3 everything works as it always have.

I have tested this mainly in Linux (Ubuntu), but I have seen the same problem in Windows as well.

Comment 1

8 years ago
Regression Range:
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.3a1pre) Gecko/20100127 Minefield/3.7a1pre
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.3a1pre) Gecko/20100128 Minefield/3.7a1pre

Comment 2

8 years ago
Mozilla/5.0 (X11; Linux i686; rv:2.2a1pre) Gecko/20110407 Firefox/4.2a1pre

Works fine for me using the latest trunk.

Bertilo can you please verify it again using the latest trunk?


Comment 3

8 years ago
I just installed the latest trunk (4.2a1pre - 2011-04-08). The test results were very confusing indeed:

At first everything worked perfectly, using the Acrobat Reader PDF plugin. But, if I remember correctly, not using Mozplugger and Evince. But then I found that it suddenly worked in the official Firefox 4 as well (both with Acrobat and Evince). ??? On the other hand that was in a newly installed Ubuntu 11.04 (beta) where Firefox 4 is actually a version packaged by Ubuntu and thus perhaps not quite the same as vanilla Firefox 4. Acrobat Reader seems to work a bit differently in Ubuntu 11.04 (it seems to use Mozplugger now). When I reported this bug I was on Ubuntu 10.10.

So I went back to my old Ubuntu 10.10, and found that the bug is still there in Firefox 4 and also in the trunk version. :(

But then when I returned to my new Ubuntu 11.04, suddenly it didn't work in the trunk version any more. But it still worked in the official Firefox 4 (Ubuntu packaged)! Perhaps tomorrow things will be different still. Utterly confusing!

So perhaps this is really a Ubuntu thing, or perhaps not. Aravindm seems to have seen the bug in Windows.

Comment 4

8 years ago
Could be an issue with the AdobeReader version you are using.

I use Adobe Reader 9.4 - and everything is working perfectly. Can you please check your version from the pluggins tab and post it in a Comment?


Comment 5

8 years ago
In my ubuntu 11.04 Adobe Reader version 9.4.2 is installed. I believe that is the latest version for Linux. (It does however have some issues in Ubuntu 11.04, probably related to the Unity interface, but PDFs are being displayed normally.)

PDF printing (in my test page) works if I use the official Ubuntu version of Firefox 4 ("Mozilla Firefox for Ubuntu Canonical - 1.0"). But when I just tested the latest trunk, which is actually Firefox 6.0a1, the print button was dead. I also found Firefox 5.0a2. Same thing: nothing happens. I'm not sure which nighly for Firefox 4 I should try. There seem to be so many confusing Nighlies now: betas, auroras...

As I mentioned before the Ubuntu version now uses Mozplugger to embed Adobe Reader. That was not the case in earlier Firefox versions in Ubuntu. So maybe they have found a way to work around this bug using Mozplugger. When I tried to use Mozplugger myself before, I had no such luck. But the Canonical guys are probably more skilled than I am...

Comment 6

8 years ago
As far as I can tell right now, this is most probably a problem with mozplugger. When mozplugger is being used to embed Acrobat Reader or Evince or anything else, then the Javascript print() command does not work. Without Mozplugger it does, so I guess this is not really a Firefox bug after all.

Now if only Firefox 4 and Acrobat Reader would get along better, I would be happy, but very often an embedded Acrobat Reader simply refuses to load PDFs, although mostly it does, at least in Linux (after twenty reloads it usually wakes up...). But that's a story for another bug report...
Version: unspecified → 4.0 Branch

Comment 7

8 years ago
tested it on a windows system. Acrobat X, and firefox 5. On this test and on my project. What was once working window.frame[id].print(); function of a pdf in an iframe, no longer functions after firefox updated. Confirmed functionality compatible with Internet Explorer 7-9, Safari, Chrome, and Opera. apparently it's a large bug. others are having the same issue (source: http://support.mozilla.com/en-US/questions/803140).

Please update on resolution of problem.

Comment 8

8 years ago
open firefox, open pdf, file --> print. Nothing.
This issue is still occurring, all the way up to Firefox 10.0.1. I can duplicate it consistently on Firefox for Windows with Adobe Acrobat (no additional third-party PDF plugins involved), so I don't think this is a mozplugger issue.

I've created a proof of concept (http://storage.michaelaquilina.com/ff-print/), which includes two iframes. One includes a PDF, while the other includes an HTML document, with buttons to print both via JavaScript. Internet Explorer and WebKit handle this properly - both buttons trigger a print dialog for the contents of the relevant iframe.

Firefox, however, handles printing the HTML iframe perfectly, but the PDF one simply fails silently with nothing emitted to the error log.

Any guidance would be greatly appreciated. If it's an Acrobat issue, I'd be happy to escalate this to Adobe, but I haven't found anything to indicate that it's an issue on their end. Thanks.

Comment 10

7 years ago
Hi, it still didn't work in Mozilla 12.0 (Win XP). Could you give any comment about that? 
Thank you.

Comment 11

6 years ago
I can confirm this still does not work in Firefox 19 with the built-in PDF viewer on Windows 7.
attempting to print as pdf with http://storage.michaelaquilina.com/ff-print/ I get 
Error: Error: Permission denied to access property 'print'
Source File: http://storage.michaelaquilina.com/ff-print/
Line: 10
For what it's worth, I tested this iframe pdf printing in Firefox 12 and it did work. However, now I only have version 21, 23 and 24 installed and it no longer works in any of them.

Comment 14

5 years ago
The problem persists in Firefox 25.0.1 with the built in viewer.

The problem is that that the PDF document embedded in the iframe has "pdf.js" as domain, no matter what the real domain is. You can check this with firebug, since the cross domain policy forbades any attempt to access the document with Javascript.

Of course, the cross domain policy applies not only to the print function but to (almost) everything.

The pdf document should point to the right domain, then everything would work. If this is not possible for security considerations or whatever, then having the pdf document answer to at a "print" message sent via postMessage could be a nice workaround for this particular case.
Same error on the 27.0.1 version

Try to print the http://storage.michaelaquilina.com/ff-print/ 

Error: Access Denied..

Comment 16

5 years ago
Same error when trying to print "http://storage.michaelaquilina.com/ff-print/"

Windows 7 64 bit
Firefox v32.0.3
Last Resolved: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 911444
You need to log in before you can comment on or make changes to this bug.