Please i want assistance on how to click a button and it downloads the pdf content for users.
Please any assistance?
This is my code
<a href="{{PDF FILE HERE}}" style="text-decoration: none;"></a>
Thank you in advance
Please i want assistance on how to click a button and it downloads the pdf content for users.
Please any assistance?
This is my code
<a href="{{PDF FILE HERE}}" style="text-decoration: none;"></a>
Thank you in advance
you can take a look at
or you can use fileopener plugin
$scope.openPDF = function(url){
switch(devicePlatform){
case 'Android':
/**
* Android devices cannot open up PDFs in a sub web view (inAppBrowser) so the PDF needs to be downloaded and then opened with whatever
* native PDF viewer is installed on the app.
*/
var fileURL = cordova.file.externalApplicationStorageDirectory+"local.pdf";
var fileTransfer = new FileTransfer();
var uri = encodeURI( url );
fileTransfer.download(
uri,
fileURL,
function(entry) {
$scope.data.localFileUri = entry.toURL();
window.plugins.fileOpener.open(entry.toURL());
},
function(error) {
},
false
);
break;
default:
/**
* IOS and browser apps are able to open a PDF in a new sub web view window. This uses the inAppBrowser plugin
*/
var ref = window.open(url, '_blank', 'location=no,toolbar=yes,closebuttoncaption=Close PDF,enableViewportScale=yes');
break;
}
}