Skip to content

Commit

Permalink
A change to #1098 to use the FileSaver library to modify and then wri…
Browse files Browse the repository at this point in the history
…te the blob instead of using jsPDF to target Firefox 98+ only
  • Loading branch information
JohnSmith-LT committed May 25, 2022
1 parent 0f27504 commit b9dad63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -57,6 +57,7 @@
filesToLoad = [
'NotoSerif-Bold.js',
'NotoSerif-Normal.js',
'FileSaver.min.js',
'jspdf.min.js',
'jspdf.plugin.autotable.min.js'
],
Expand Down Expand Up @@ -564,8 +565,12 @@

// Workaround for Firefox/98.0 default opening issue
let firefox = navigator.userAgent.indexOf("Firefox");
if (parseInt(navigator.userAgent.substr(firefox + 8, 4)) >= 98)
window.open(pdf.output("bloburl", { filename: name.replace(/ /g, "_") }));
if (parseInt(navigator.userAgent.substr(firefox + 8, 4)) >= 98) {
console.warn('Firefox 98+ detected - using alternative PDF save way...');
let blob = pdf.output('blob');
blob = blob.slice(0, blob.size, 'application/octet-stream');
saveAs(blob, name.replace(/ /g, "_"));
}
else
pdf.save(name.replace(/ /g, "_"));
}
Expand Down

0 comments on commit b9dad63

Please sign in to comment.