Print PDF in iframe using JavaScript in Firefox

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

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

I have a PDF embedded in an object tag. I need to be able to print PDF using the JavaScript function in Firefox. Placing a PDF in an iframe and printing do not work, because Firefox will not allow you to access the contents of the frame. Also not used:

 myObject.contentWindow.print(); 

or

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

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

+5
source share
1 answer

Unfortunately, as @yms said in the comments, this is a bug in Firefox, and there is no workaround so far. You can read the bug report here . It seems that no progress in the correction is observed, but I will update this answer as soon as I find out about it.

+1
source

Source: https://habr.com/ru/post/1201154/


All Articles