You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Facing Issue while download the file.

Accepted answer
72
Views
7
Comments

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);

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!