This website collects cookies to deliver better user experience
Download Browser Page as PDF using JavaScript
Download Browser Page as PDF using JavaScript
Hello folks, today we will cover how to save our browser page as pdf. We will generate pdf using Vanilla JavaScript. This functionality can be used to generate invoices or receipts for users.
♣️ I decide to write the whole code in index.html, feel free to refactor it to your convenience. The invoice template is gotten from Bootsnip written by heidilux. I made a little tweaking to the template to tailor it to this project.
🎯 First of all, add the html2pdf CDN script to the head of your HTML boilerplate.
🎯 Next, Let's flesh out our div container in index.html that holds all the data contained in the invoice.
📝 Ensure you wrap the content to display in the div.