I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
There is a problem with the Document Viewer docs.
The example says:
const options = {
title: 'My PDF'
}
this.document.view('assets/myFile.pdf', 'application/pdf', options)
However:
view. DocumentViewerOptions[]. Is this actually correct? Why is it an array?Hey @dylanvdmerwe,
the example is wrong. The right method is called viewDocument().
I fixed it and your second question too (no array).
so, how to declare the options?
If I add DocumentViewerOptions to my imports and add
`IonViewDidEnter(){
const options: DocumentViewerOptions = {
title: 'My PDF'
}
this.document.viewDocument('assets/pdf/firebase.pdf', 'application/pdf', options)
}`
Then I get no errors.
However how do I actually display the pdf?
I use it like this:
constructor(platform: Platform, public navCtrl: NavController, public navParams: NavParams, private document: DocumentViewer) {
platform.ready().then(() => {
const options: DocumentViewerOptions = {
title: 'RCP'
};
this.document.viewDocument('http://website.com/file.pdf', 'application/pdf', options);
});
For the above example(with online hosted pdf) I got this errors:
Error in SitewaertsDocumentViewer.canViewDocument(): Objectdetails: "java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.io.File.exists()' on a null object reference↵ at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.canGetFile(DocumentViewerPlugin.java:678)↵ at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.doExecute(DocumentViewerPlugin.java:351)↵ at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.access$000(DocumentViewerPlugin.java:48)↵ at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin$1.run(DocumentViewerPlugin.java:184)↵ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)↵ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)↵ at java.lang.Thread.run(Thread.java:818)↵"message: "Attempt to invoke virtual method 'boolean java.io.File.exists()' on a null object reference"status: 9__proto__: Object
plugins/cordova-plugin-document-viewer/www/sitewaertsdocumentviewer.js:344 Error in SitewaertsDocumentViewer.viewDocument():
If I use local path this.document.viewDocument('./assets/file.pdf', 'application/pdf', options); I get:`
Error in SitewaertsDocumentViewer.canViewDocument(): {status: 9, message: "Relative URIs are not supported.", details: "java.lang.IllegalArgumentException: Relative URIs …a:588)↵ at java.lang.Thread.run(Thread.java:818)↵"}
sitewaertsdocumentviewer.js:344 Error in SitewaertsDocumentViewer.viewDocument(): {status: 9, message: "Relative URIs are not supported.", details: "java.lang.IllegalArgumentException: Relative URIs …a:588)↵ at java.lang.Thread.run(Thread.java:818)↵"}
Still don't know how to use and make this work...
@tHesTx i have the exact same scenario, how did you manage to solve it?
Most helpful comment
I use it like this:
For the above example(with online hosted pdf) I got this errors:
If I use local path
this.document.viewDocument('./assets/file.pdf', 'application/pdf', options);I get:`Still don't know how to use and make this work...