@NFB wrote:
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”;
link.download = fileName;
link.click();
};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 => {
this.fileOpener.open(
res.toInternalURL(),
‘application/pdf’
).then((res) => {}).catch(err => { console.log(err) }); }).catch(err => { console.log(err) }); }).catch(err => { console.log(err) });
third try: Again, download in web but not in android device
andfourth 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.
Posts: 1
Participants: 1