Facing Issue while download the file.
Summary:
I'm able to download the file but when i tried to open the file it shows failed to load PDF Document.
Content (required):
Code Snippet (add any code snippets that support your topic, if applicable):
JAVASCRIPT CODE
class PageModule {
constructor() {}
preview(blobData, contentTypeParam) {
let contentType = contentTypeParam;
if (contentType === undefined || contentType.length === 0) {
contentType = "multipart/form-data";
}
let newBlob = new Blob([blobData], {
type: contentType,
});
return URL.createObjectURL(newBlob);
}
download(blobData, contentType, fileName) {
let element = document.createElement("a");
element.setAttribute("href", this.preview(blobData, contentType));
element.setAttribute("download", fileName);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);