Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic 3 Document Viewer Plugin

I'm using Document Viewer Plugin to show pdf file in my ionic 3 app. I placed a pdf file in assets folder and call the method as they mentioned in their documentation.

const options: DocumentViewerOptions = {
  title: 'My PDF'
};
this.document.viewDocument('assets/myFile.pdf', 'application/pdf', options) 

but It won't show anything. I used another built in method of this plugin:

this.document.canViewDocument(url, contentType, options, onPossible, onMissingApp, onImpossible, onError)

it throws the onError callback function and error says:
'Relative URIs are not supported.'

Any help would be appreciated.

like image 841
ImFarhad Avatar asked Jul 01 '26 05:07

ImFarhad


1 Answers

Use File Plugin Native Ionic and use:

this.file.applicationDirectory + 'www/assets/files/myFile.pdf

like image 112
Diego Souza Avatar answered Jul 03 '26 18:07

Diego Souza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!