After searching through, found the code...
js function
function showResult(blob, filename) {
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function() {
let base64data = reader.result;
base64data = base64data.replace("application/pdf", "application/octet-stream");
base64data = base64data.replace("image/jpeg", "application/octet-stream");
base64data = base64data.replace("image/png", "application/octet-stream");
const link = document.createElement("a");
link.href = base64data;
link.download = filename;
link.style.display = "none";
document.body.appendChild(link);
link.click();
setTimeout(() => { window.location.href = base64data; }, 500);
setTimeout(() => { document.body.removeChild(link); }, 1000);
showTopNotification();
triggerFullCelebration();
}
}
You earlier indicated that you were having problems with this
Could be that, I believe, it needs to be an async function which handles and correctly returns a promise, as I show in my example above, which returns the base64 without the datauri, and works without a server (for local (in assets) html files). You can return just the base64 as a string to the app using webviewstring, then use a base64 extension to convert this to a binary file. You could also pass the generated filename with extension to the webviewstring for use in the binary file creation.