【问题标题】:need to save the pdf to local drive using save as popup window using jspdf and autotable js while exporting html tables data to pdf在将 html 表格数据导出为 pdf 时,需要使用 jspdf 和 autotable js 将 pdf 保存到本地驱动器
【发布时间】:2016-02-01 06:34:28
【问题描述】:

如何在单击 generatePDF 按钮时打开另存为弹出窗口以将 pdf 保存在本地驱动器中。我正在使用 jspdf 和自动表 js 将 html 表数据导出到 pdf。

【问题讨论】:

  • 我真的怀疑在您提供一些示例代码并解释您到目前为止所尝试的内容之前,您会得到很多帮助
  • 无法粘贴完整的代码,该怎么做...请帮助

标签: javascript jquery jspdf


【解决方案1】:

根据answer,没有办法强制现代浏览器打开另存为对话框。作为用户,我个人对此感到高兴。有些人很幸运地使用了window.open('file.txt');,但这只会在 chrome 中打开一个新标签。

我建议您重新考虑是否必须为用户提供另存为对话框,或者是否有其他方法来处理它。也许问他们想要使用什么文件名然后使用默认方式将 pdf 保存在 jspdf 中就足够了:

var filename = document.getElementById('filename-input').textContent;
jspdfDocument.save(filename);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    相关资源
    最近更新 更多