Now, let's see article of jquery print iframe pdf file. i would like to show you javascript print pdf file iframe. i explained simply about print iframe content pdf file using javascript. you can see how to print iframe content using javascript.
Here, i will give you very simple example how to print iframe content using jquery and javascript. if you open html code or pdf file on your iframe then you can simply print it using jquery.
You can can see bellow solution and bellow full example that will help you.
Solution:
var myIframe = document.getElementById("ipdf").contentWindow;
myIframe.focus();
myIframe.print();
return false;
Example:
make sure you have mypdf.pdf file on your location so it will display in iframe.
So, please keep one file there.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>How to print iframe content using jquery - HDTuto.com</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<button>Print</button>
<iframe id="ipdf" src="NHPFORMTEST.pdf" width="880" height="900"></iframe>
</body>
<script type="text/javascript">
$("button").click(function(){
var myIframe = document.getElementById("ipdf").contentWindow;
myIframe.focus();
myIframe.print();
return false;
});
</script>
</html>
I hope it can help you...
Do you like below Tutorials ?
- React JS Http Post Request Example
- React JS Http Delete Request Example
- Angular 9 Multi Select Dropdown Example
- How to Use Multi Select Dropdown in Angular?
- Laravel Install and Use Ckeditor Example
- Laravel Summernote Editor Example Tutorial
- Laravel Bootstrap Wysihtml5 Editor Example
- Multidimensional Array Search By Value in PHP