I have an iframe which needs point directly to a PDF file (not a page with a PDF):
<iframe id="ecard-pdf" name="ecard-pdf" style="position: absolute;" src="/profile.pdf">
</iframe>
I want to be able to print the PDF in this iFrame
I have found several solutions in other questions that do not fit my needs:
- Require to have a function in the iframe ( https://stackoverflow.com/a/473270/1246369 )
- Suggest focusing the frame and then performing print action on it ( https://stackoverflow.com/a/9616706/1246369 )
- Access contentWindow of the iframe and print it ( https://stackoverflow.com/a/9617566/1246369 )
- Variations of those
However, it seems that FireFox and IE can't do this if the iframe's src points directly to a PDF and not to a page wrapped around the PDF.
Firefox:
Instead of printing, it displays this dialog: "Prevent this page from creating additional dialogues" with "OK" and "Cancel" buttons, neither of which prints the PDF.
IE:
just ignores my attempts to print using the above methods.
Question:
How can I allow users to print the PDF in the iFrame no matter what browser they are using?
As suggested in this answer for a similar question, you could do this:
This should solve your problem.
Option 1:
I haven't tested this but I found another answer here: https://stackoverflow.com/a/4096547/2528978
Assuming that you could use the following:
So then just the pdf is displayed?
Option 2:
Make a hyperlink to the pdf file that says "Print me"
Hope this helps...
-Andrew
You can use directly window print option. use onclick option
onclick="javascript:window.print();"
I have struggled a bit to find a solution that works for both IE and Chrome. This works for me:
...cheers.
This seems to be working:
So then just the pdf is displayed?