Invalid absolute docBaseUrl "blob"

2.7k views Asked by At

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.

0

There are 0 answers