【发布时间】:2018-11-12 09:13:06
【问题描述】:
我尝试制作一个按钮,将我的 HTML 页面转换为 PDF 并下载它,但我无法让它工作。例如,如果这是页面:
function download() {
print()
}
<html>
<body>
<h2>Page Content</h2>
<br>
<p>The page content will go <span style="color:red;">here...</span></p>
<br><br>
<button onclick="download()">Download Page</button><br>
^ The above button uses the <code>print()</code> function. However, this prompts the user with a print page, instead of asking to download.
</body>
</html>
print() 函数的按钮,但是它要求用户打印页面,而不是下载它。
有谁知道如何将 HTML 页面转换为 pdf 以供下载?
【问题讨论】:
-
请添加更多工作细节,似乎有一些 js 库可以做到这一点。您尝试过其中任何一个吗?
标签: javascript html pdf