How to print Iframe content using jQuery?

AuthorHariom Prajapati

Pubish Date30 Jun 2022


In this tutorial we will learn how to print iframe content using jQuery.

Here we will use contentWindow to print iframe content using jQuery.



var printIframe = document.getElementById("iframePdf").contentWindow;
    printIframe .focus();
    printIframe .print();
    return false;


Example -

First of all you need to make sure that you have pdfFile.pdf on location so it display on iframe.

<html xmlns="">

    <title>print iframe content using jquery</title>
    <script src=""></script>

    <button>Print it</button>
    <iframe id="iframePdf" src="pdfFile.pdf" width="880" height="900"></iframe>

<script type="text/javascript">
    $("button").click(function () {
        var printIframe = document.getElementById("iframePdf").contentWindow;
        return false;

Comments 0

Leave a comment