By Rituraj
This Project focuses on Printing the content of the Page from the console using JavaScript and Downloading the Page content in pdf format.
Requirements:
1. JavaScript file for executing the project.
Printing the content of the page:
1. For Printing the page content You have to just write
window.print()
2. This code will open a separate window that will give options for printing the entire content of the page.
Downloading the content of the page in pdf format:
1. Taking the Reference of the HTML file in the project.
2. Include the CDN file of the html2pdf file in the HTML file given the link in the header format.
3. Now in the Js file take the content of the project in a variable i.e dwn using the DOM reference as document.getElementById().
window.onload= function() { document.getElementById("download").addEventListener("click",()=> { const dwn=this.document.getElementById("dwn"); html2pdf().from(dwn).save() }) }
4. For conversion use html2pdf() to get the content of the page in pdf format.
Submitted by Rituraj (riturajoctober)
Download packets of source code on Coders Packet
Comments