【发布时间】:2016-05-25 03:50:27
【问题描述】:
我正在尝试使用这个库https://github.com/hrikrishnankr/Pdf2Html 上传pdf并下载html文件。我已经能够使用
成功下载 html 文件function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/html;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
然后我有这个从查看器获取 html
var data=document.getElementById("viewer").innerHTML;
并在单击按钮下载按钮时运行该函数
<button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="34" data-l10n-id="download"
onclick="downloadhtml()">
function downloadhtml() {
var data=document.getElementById("viewer").innerHTML;
download('file.html', data);
}
但我得到的文件主要是加载的空 div 容器
<div class="loadingIcon"></div>
据说它应该已经内置了pdf2html转换功能。加载完成后如何在查看器中获取html并将其下载到文件中?
【问题讨论】:
标签: javascript jquery html pdf