Check out Ionic Enterprise

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
    
  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 Array<DocumentViewerOptions>

options

onShow Function

Optional

onClose Function

Optional

onMissingApp Function

Optional

onError Function

Optional

DocumentViewerOptions

Param Type Details
title string
documentView { closeLabel: string; }
navigationView { closeLabel: string; }
email { enabled: boolean; }
print { enabled: boolean; }
openWith { enabled: boolean; }
bookmarks { enabled: boolean; }
search { enabled: boolean; }
autoClose { onPause: boolean; }

API

Native

General