此代码让我下载 pdf,但将其放入 iframe 时出错:
docNormale.save('Ordini.pdf');
var iframe = document.getElementById('outputPDFnormale');
iframe.style.width = '60%';
iframe.style.height = '650px';
iframe.src = docNormale.output('datauristring');
这段代码让我在 iframe 中插入 pdf,但在下载 pdf 时出现错误:
var iframe = document.getElementById('outputPDFnormale');
iframe.style.width = '60%';
iframe.style.height = '650px';
iframe.src = docNormale.output('datauristring');
docNormale.save('Ordini.pdf');
两种情况下的错误都是相同的,它是:Uncaught TypeError:无法读取未定义的属性“toFixed”
我使用的是最新版 Chrome
最佳答案
这是库上的错误/限制,save() 是一个输出操作,atm 不支持两个这样的连续操作,因此请随意在其问题跟踪器上提交错误:https://github.com/MrRio/jsPDF/issues
同时,这应该有效:
var rawdata = docNormale.output();
var len = rawdata.length,
ab = new ArrayBuffer(len),
u8 = new Uint8Array(ab);
while(len--) u8[len] = rawdata.charCodeAt(len);
var blob = new Blob([ab], { type : "application/pdf" });
saveAs(blob, 'Ordini.pdf');
var iframe = document.getElementById('outputPDFnormale');
iframe.style.width = '60%';
iframe.style.height = '650px';
iframe.src = URL.createObjectURL(blob);
关于javascript - JsPDF .save() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25263605/