Problem to download pdf in base 64

I have a problem when i’ll try download pdf in base 64, I’ve tried a lot of ways but it doesn’t work.

When i’ll try download in android device not work, but if is in web i don’t have any problem.

First try: Download in web but not in android device

var array = base64ToArrayBuffer(x);

 var sampleArr = base64ToArrayBuffer(base);
  saveByteArray(name, sampleArr);

function base64ToArrayBuffer(base64) {
var binaryString = window.atob(base64);
var binaryLen = binaryString.length;
var bytes = new Uint8Array(binaryLen);
for (var i = 0; i < binaryLen; i++) {
var ascii = binaryString.charCodeAt(i);
bytes[i] = ascii;
return bytes;

function saveByteArray(reportName, byte) {
var blob = new Blob([byte]);
var link = document.createElement(‘a’);
link.href = window.URL.createObjectURL(blob);
var fileName = reportName + “.pdf”; = fileName;;

Second try: externalApplicationStorageDirectory || ApplicationDirectory not found the route

let downloadPDF: any = ‘mybase64’
fetch(‘data:application/pdf;base64,’ + downloadPDF,
method: “GET”
}).then(res => res.blob()).then(blob => {
this.file.writeFile(this.file.externalApplicationStorageDirectory, ‘name.pdf’, blob, { replace: true }).then(res => {
).then((res) => {

          }).catch(err => {
        }).catch(err => {
      }).catch(err => {

third try: Again, download in web but not in android device


fourth try: window.resolveLocalFileSystemURL doesn’t exist in window and i’ll try the answer window[‘resolveLocalFileSystemURL’] is not a function.

I need download pdf, please heeeeelp me.

Regards and thanks for help.

sth like that: How to download file natively? ?

Typescript error? you have to define it in your declarations.d.ts first so that typescript knows that it exists or use a plugin from Native APIs - Build Open-Source Native Application Experiences they have a manual on how to do it and typescript wrapers.

Thanks for the reply.

I have a question: I get the base64 from a web service and this return me a XML from where I take the base64.

With this plugin “” can i use it the plugin in the same way or i can’t use it because this plugin need a uri.


This plugin has some caveats: It only works on android and it is not actively maintained.

alternative: File Transfer | Cordova Docs File Transfer Download Plugin(works on iOS an android)

I wouldn’t use base64 for this unless there is a better way, becaue files get ~30% bigger with base64.

Then use the file plugin File API Plugin for Read and Write File Access on Devices to save the file after you converted it from the base64 returned by your webservice to a pdf file.

Dear @NFB,

did your problem is fixed . I am also in same issue. But it work in some version of Android …

please see my thread and advise : base64 pdf issue