Adding a "Download PDF" button on a webpage can give the user an option to print only a certain section of your webpage in PDF format. This feature is of great use if your website is used to generate a report. That report (or anything else) can be placed inside a DIV and then a "Download PDF" or "Print PDF" button can be added into it to download contents of that particular DIV. Usually a website/webpage contain a lot of content, such as sidebars and related posts, in which user might not be interested in printing.
Without wasting any time lets show you the javascript and HTML code.
The code will be implemented in two parts: HTML and Javascript.
HTML Part
Print me
In the above code you may change id of div as per your need to print only a particular div.
Javascript Part
Note: This button opens the simple printing interface, from where you can either choose to print by selecting a printer or saving the preview content as PDF.