3

The below code is not working in Internet explorer asking for additional tools in client side.

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's HTML with div's 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;

}
Leandro Bardelli
  • 10,561
  • 15
  • 79
  • 116
  • 2
    Additional tools ? What do you mean by this ? Also close the html tag. – Mairaj Ahmad Apr 20 '15 at 06:04
  • pdf generator tools like pdf 995, nitro etc.. – Ravisankar Reddy Apr 20 '15 at 06:06
  • 1
    You can only solve this without additional installation at user side by preparing a pdf-file serverside. This means you render a pdf using what ever serverside technology you use and send it to the client. I guess you should read this: http://stackoverflow.com/questions/570179/generate-pdf-from-asp-net-from-raw-html-css-content – Nico O Apr 22 '15 at 16:46

1 Answers1

0

window.print() will just open the browsers print dialog. So if you want to safe the printout as pdf you need a pdf printer driver installed on your operating system.

gwildu
  • 3,621
  • 1
  • 17
  • 22
  • client need printer driver !!!, i need direct print to pdf client side without any plugins like pdf generator – Ravisankar Reddy Apr 20 '15 at 08:57
  • @RavisankarReddy, what you are asking for is not possible to do, or maybe you are not expressing correctly when asking. – zed Apr 22 '15 at 16:46