Skip to content

Commit e5f6e45

Browse files
committed
Fix - store PDF file with images
Raw string has special symbols which does not work directly with JS Blob object. One need to convert string to ArrayBuffer before providing it to Blob
1 parent cef0a07 commit e5f6e45

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

modules/gui/utils.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,12 @@ async function saveFile(filename, content) {
564564
if ((content.length > 1e6) && (contentType === 'application/pdf')) {
565565
// large PDF files do not work in the browser with plain base64 coding
566566
const bindata = getBinFileContent(content),
567-
blob = new Blob([bindata], { type: contentType });
567+
len = bindata.length,
568+
buffer = new ArrayBuffer(len),
569+
view = new DataView(buffer, 0, len);
570+
for (let i = 0; i < len; ++i)
571+
view.setUint8(i, bindata.charCodeAt(i));
572+
const blob = new Blob([buffer], { type: contentType });
568573
fileURL = URL.createObjectURL(blob);
569574
a.href = fileURL;
570575
} else

0 commit comments

Comments
 (0)