无效的绝对docbaseurl“ blob”
我有一个旧脚本的新问题。旧的(1.5.3)和最新(2.5.1)JSPDF版本已经存在问题。
直到最近,在浏览器中创建PDF时仍显示“保存或查看”对话框。现在,仅当禁用浏览器(Firefox)以显示PDF时,它才能起作用。在默认模式下,PDF显示为 blob ,并且在JSPDF中没有脚本指定的文件名中具有URL。
控制台显示消息警告:无效的绝对docbaseurl:“ blob:https://www.example.com/25dao98-787zhz98-098kiio54”。 / example.com](pdf.js:2.14.13)。
创建PDF时,我该怎么做才能在浏览器中再次打开“保存或查看”对话框?
我在我的网站中使用CDN(JSPDF.MIN.JS)版本,仅使用简单的绘图,文本,字体和图像函数。
这里是JSPDF GitHub页面的一个示例:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
</head>
<body>
<script>
function myfunc() {
var { jsPDF } = window.jspdf;
var doc = new jsPDF();
doc.setFont(undefined, 'normal');
doc.text("Hello world! " + Date.now(), 10, 10);
doc.setFont(undefined, 'bold');
doc.text("Hello world! " + Date.now(), 10, 20);
doc.save("a4.pdf");
}
</script>
<button onclick="myfunc();">Button</button>
</body>
这是我的网站空间上的JSPDF.HTML,在Firefox中,它打开了 blob 。在JSFiddle上,使用正确的文件名将PDF文件保存在默认下载目录中,并在新选项卡中打开它。
https://jsfiddle.net/awk6hd7t/
我不需要blob。
I have a new problem with an old script. The problem is already exist with an old (1.5.3) and the newest (2.5.1) jsPDF version.
Until recently, the Save or View dialog was displayed when creating a PDF in the browser. Now it works only if the browser (Firefox) is disabled to show PDF. In default mode the PDF is displayed as blob and has a URL without the filename specified by the script in jsPDF.
The console displays the message Warning: Invalid absolute docBaseUrl: "blob:https://www.example.com/25dao98-787zhz98-098kiio54".
and PDF 7a55842e15bbd5545545114f2211 [1.3 jsPDF 2.5.1 / example.com] (PDF.js: 2.14.13)
.
What do I have to do to open the Save or View dialog in the browser again when creating the PDF?
I use the CDN (jspdf.min.js) versions in my website and only uncomplicated draw, text, font and image function.
Here a example from the jsPDF Github page:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
</head>
<body>
<script>
function myfunc() {
var { jsPDF } = window.jspdf;
var doc = new jsPDF();
doc.setFont(undefined, 'normal');
doc.text("Hello world! " + Date.now(), 10, 10);
doc.setFont(undefined, 'bold');
doc.text("Hello world! " + Date.now(), 10, 20);
doc.save("a4.pdf");
}
</script>
<button onclick="myfunc();">Button</button>
</body>
This as jspdf.html on my webspace and in firefox opens a blob. And the same on jsfiddle save the pdf file in the default download directory with the correct filename and opens it in a new tab.
https://jsfiddle.net/awk6hd7t/
I don't need blob.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论