如何在没有asp.net客户端的任何工具的情况下将div保存为PDF?

时间:2015-04-20 05:42:22

标签: javascript jquery html css asp.net

以下代码无法在Internet Explorer中请求客户端的其他工具。

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;

}

1 个答案:

答案 0 :(得分:0)

window.print()将只打开浏览器打印对话框。因此,如果您想以PDF格式安全打印输出,则需要在操作系统上安装pdf打印机驱动程序。