How to Print Iframe Content using Jquery?

How to Print Iframe Content using Jquery?

In this post we will give you information about How to Print Iframe Content using Jquery?. Hear we will give you detail about How to Print Iframe Content using Jquery?And how to use it also give you demo for it if it is necessary.

Hi Dev,

Today, i would like to show you how to print iframe content using javascript. In this article, we will implement a jquery print iframe content only. if you want to see example of print iframe content using jquery then you are a right place. you will learn jquery print iframe pdf file. You just need to some step to done javascript print pdf file iframe.

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.

Also see:Jquery Input Mask Phone Number Validation Example

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>How to print iframe content using jquery - ItSolutionStuff.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…

Hope this code and post will helped you for implement How to Print Iframe Content using Jquery?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  62  =  66

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US