[英]export div content to a pdf file using javascript
我有一些文本框或完全包含在 div 中的表單。 我想提供一個選項,以便在單擊按鈕時將該 div 內容下載為 pdf 文件並僅使用 javascript。 請幫我解決這個問題
試試這個代碼
function printChart() {
pvwindow = window.open('', 'PrintWindow', ' location = 0, status = 0, scrollbars = 1, width = 750, height = 600')
pvwindow.document.write("<html>");
pvwindow.document.write("<head>");
pvwindow.document.write("</head>");
pvwindow.document.write("<body style='background-color:white;' onload='window.print();'>");
pvwindow.document.write(document.getElementById("print_div").innerHTML);
pvwindow.document.write("</body>");
pvwindow.document.write("</html>");
pvwindow.document.close();
}
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.