Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Document Viewer

Improve this doc

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

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-document-viewer
    $ npm install --save @ionic-native/document-viewer@4
    
  2. Add this plugin to your app's module

Supported platforms

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)
email { enabled: boolean; } (optional)
print { enabled: boolean; } (optional)
openWith { enabled: boolean; } (optional)
bookmarks { enabled: boolean; } (optional)
search { enabled: boolean; } (optional)
autoClose { onPause: boolean; } (optional)

API

Native

General