How to save div as PDF without any client side tooling in asp.net?

The code below does not work in Internet Explorer requesting additional client side tools.

function printDiv(divID) {
    //Get the HTML of div
      var divElements = document.getElementById(divID).innerHTML;
    //Get the HTML of whole page
    var oldPage = document.body.innerHTML;
    //Reset the page HTML with div HTML only
    document.body.innerHTML = "<html><head></head><body>" + divElements + "</body>";
    //Print Page
    window.print();
    //Restore orignal HTML
    document.body.innerHTML = oldPage;
    //disable postback on print button
    return false;

}

      

+3


source to share


1 answer


window.print()

will open the browsers print dialog. Therefore, if you want to save the printout in pdf format, you will need the PDF printer driver installed on your operating system.



0


source







All Articles