Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor JSRUNTIME iframe not working with blob

$
0
0

I have this in an private async Task method

await JsRuntime.InvokeVoidAsync("Test");

and is working with this :

async function Test() {    return await new Promise((resolve) => {        iframe = document.createElement('iframe');        iframe.style.display = 'none';        iframe.src = "https://localhost/order/create";        document.body.appendChild(iframe);        iframe.onload = function () {            setTimeout(function () {                iframe.contentWindow.print();            }, 1);        };        iframe.contentWindow.onafterprint = function () {            resolve();        }    })}

but when i use a blob my promise don't return anything and i don't know why :

async function BlazorDownloadFile(content) {    return await new Promise((resolve) => {        var blob = new Blob([content], { type: 'application/pdf' });         var blobURL = URL.createObjectURL(blob);        iframe = document.createElement('iframe');         iframe.style.display = 'none';        iframe.src = blobURL;        document.body.appendChild(iframe);        iframe.onload = function () {            setTimeout(function () {                iframe.contentWindow.print();            }, 1);        };        iframe.contentWindow.onafterprint = function () {            resolve(true);        }    })}

Can someone help me...


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>