[FIXED] Can't download base64 pdf file [Network issue]

Issue

I have a base64 pdf that I get from local storage I want to be able to download this with vue3 typescript.

downloadPDF() {
      const linkSource = `data:application/pdf;base64,${'json.base64'}`;
      const downloadLink = document.createElement("a");
      const fileName = this.jsonFile.name + ".pdf";
      downloadLink.href = linkSource;
      downloadLink.download = fileName;
      downloadLink.click();
    },

error:Network issue when download

Solution

After a few day I founded a way.

I’ve to add this.json.base64 not only json.base64 in this line below.

const linkSource = `data:application/pdf;base64,${this.json.base64}`;

Answered By – Nawapol R.

Answer Checked By – Timothy Miller (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published