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…
New contributor
ADG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.