Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing a PDF in an iframe using JavaScript in Firefox

I was wondering if it is possible to print the data of an object tag in html? For example I have an object like this:

<object id="myObject" data="myPDF.pdf"></object>

I have a PDF embedded in the object tag. I need to be able to print the PDF using a JavaScript function in Firefox. Placing the PDF in an iframe and printing does not work as Firefox will not let you access the frame's contents. Neither does using:

myObject.contentWindow.print();

or

document.getElementById("myObject").print(); 

Does anyone have any other suggestions? I am trying to figure out a way of printing just the data of the object (i.e. the PDF file) but have not found a solution so far. Using an iframe works for chrome and using an embed tag works for Internet Explorer, but I cannot find anything that will work in Firefox. Any help is much appreciated, thanks.

like image 731
Celt Avatar asked Nov 10 '22 02:11

Celt


1 Answers

Unfortunately as @yms said in the comments this is a bug in Firefox and there is no workaround for it yet. You can read the bug report here. There does not seem to be any progress on a fix but I will update this answer as soon as I hear of one.

like image 175
Celt Avatar answered Nov 14 '22 22:11

Celt