I write here the same question because anyone answered to me…
Hi guys,
I’ve a trouble with download of a PDF file created with pdfmake. I have created and viewed the pdf made from charts.js, but now I would like to download the file.
I tried to use ngCordova:
…
var blob = new Blob([pdf], {type: ‘application/pdf’});
…
$scope.pdfUrl = URL.createObjectURL(blob);
…
$cordovaFile.writeFile(cordova.file.dataDirectory,‘fileName.pdf’,$scope.pdfUrl, true).then(function(result){
alert(‘Success! Survey created!’);
}, function(err) {
console.log(“ERROR”);
})
But I got an error 1: NOT_FOUND_ERR
What’s wrong? Please help me…I’m going crazy!! Thank you all guys
I used writeFile(path, file, data, replace) method in $cordovaFile to write new file(pdf, jpg, text ).
as a data I got data stream from restful service …(it looks like %PDF-1.5↵%����↵1 0 obj↵…)
The problem is I can write a file but it opens as a blank pdf but file size is correct.
for data field I used data stream itself, blob object(var blob = new Blob([data], { type: ‘application/pdf’ }) ,
I used writeFile(path, file, data, replace) method in $cordovaFile to write new file(pdf, jpg, text ).
as a data I got data stream from restful service …(it looks like %PDF-1.5↵%����↵1 0 obj↵…)
The problem is I can write a file but it opens as a blank pdf but file size is correct.
for data field I used data stream itself, blob object(var blob = new Blob([data], { type: ‘application/pdf’ }) ,
I am trying to use writeFile in Ionic on Android. It works writing the file to the directory
Android/data/com.ionicframework.myappname/cache but it does not work for the directory
Android/data/com.ionicframework.myappname/files
The paths are correct as I checked using alert. Is there a permission problem? The files directory is empty.