Document Viewer
This plugin offers a slim API to view PDF files which are either stored in the apps assets folder (/www/*) or in any other file system directory available via the cordova file plugin.
Repo: https://github.com/sitewaerts/cordova-plugin-document-viewer
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-document-viewer $ npm install --save @ionic-native/document-viewer@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
- Windows
Usage
import { DocumentViewer } from '@ionic-native/document-viewer';
constructor(private document: DocumentViewer) { }
...
const options: DocumentViewerOptions = {
title: 'My PDF'
}
this.document.viewDocument('assets/myFile.pdf', 'application/pdf', options)
Instance Members
getSupportInfo()
Displays the email composer pre-filled with data.
Returns: Promise<any>
Resolves promise when the EmailComposer has been opened
canViewDocument(url, contentType, options, onPossible, onMissingApp, onImpossible, onError)
Check if the document can be shown
Param | Type | Details |
---|---|---|
url |
string
|
Url to the file |
contentType |
string
|
Content type of the file |
options |
Array<DocumentViewerOptions>
|
options |
onPossible |
Function
|
Optional |
onMissingApp |
Function
|
Optional |
onImpossible |
Function
|
Optional |
onError |
Function
|
Optional |
viewDocument(url, contentType, options, onShow, onClose, onMissingApp, onError)
Opens the file
Param | Type | Details |
---|---|---|
url |
string
|
Url to the file |
contentType |
string
|
Content type of the file |
options |
DocumentViewerOptions
|
options |
onShow |
Function
|
Optional |
onClose |
Function
|
Optional |
onMissingApp |
Function
|
Optional |
onError |
Function
|
Optional |
DocumentViewerOptions
Param | Type | Details |
---|---|---|
title |
string
|
(optional) |
documentView |
{
closeLabel: string;
}
|
(optional) |
navigationView |
{
closeLabel: string;
}
|
(optional) |
{
enabled: boolean;
}
|
(optional) | |
{
enabled: boolean;
}
|
(optional) | |
openWith |
{
enabled: boolean;
}
|
(optional) |
bookmarks |
{
enabled: boolean;
}
|
(optional) |
search |
{
enabled: boolean;
}
|
(optional) |
autoClose |
{
onPause: boolean;
}
|
(optional) |