How To Print Specific Area Of Webpage Using Jquery

How To Print Specific Area Of Webpage Using Jquery

How To Print Specific Area Of Webpage Using Jquery

0 Sales

Free

This article offers an easy way to print certain content or full page content via JavaScript. Here we construct a Div content, site field, and full web page content feature in the form of JavaScript.

 

PrintPageArea() has some JavaScript code that can be easily implemented on the web page for printing. It offers the easiest way to print out a specific web page area.


 

JavaScript Code:

 

PrintPageArea() opens a new web page content window and printing option based on the ID element provided. You can use this function to print a specific web page area or full web page content.

 

function printPageArea(areaID){

    var printContent = document.getElementById(areaID);

    var WinPrint = window.open('', '', 'width=900,height=650');

    WinPrint.document.write(printContent.innerHTML);

    WinPrint.document.close();

    WinPrint.focus();

    WinPrint.print();

    WinPrint.close();

}


Use the printPageArea() function on the Print button element event and provide the content area of the div ID that you want to print.


printPageArea('elementID')

HTML Code:

The print button that will trigger the printPageArea() function by clicking on it.

Print


HTML content which needs to be printed.

All the printable content goes here......

LICENSE OF USE

You can use it for personal or commercial projects. You can't resell it partially or in this form.

PRODUCT INFO

Create Date : May 14, 2020

Updated Date : May 14, 2020

Ratings

Comments : 0

Downloads : 0