i have a web form and i need to export DIV to PDF that i marked following image .

i have a web form and i need to export DIV to PDF that i marked following image .

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Dec 19, 2022, 4:51 AM EST
use JSPdf, add below line inside head section of your html page
Then copy paste below code
var doc = new jsPDF(); function saveDiv(divId, title) { doc.fromHTML(`${title}` + document.getElementById(divId).innerHTML + ``); doc.save('div.pdf'); } function printDiv(divId, title) { let mywindow = window.open('', 'PRINT', 'height=650,width=900,top=100,left=150'); mywindow.document.write(`${title}`); mywindow.document.write(''); mywindow.document.write(document.getElementById(divId).innerHTML); mywindow.document.write(''); mywindow.document.close(); // necessary for IE >= 10 mywindow.focus(); // necessary for IE >= 10*/ mywindow.print(); mywindow.close(); return true; }now inside print button click simply pass the desired div id
$("#btnPrint").click(function(){ saveDiv("divMain","MyPdf"); });tharanga sahabandu91 reputationPosted Dec 22, 2022, 2:12 AM EST
Thanks Bro