How to Display .pdf, .xlsx, .docx Files in a Cordova App


Build-in handlers for displaying .pdf, .xlsx, .docx and other file types are usually not available on mobile devices. If your mobile app is built using Cordova, you can use the Document Handler Cordova plugin to display these file types.


The Cordova Document Handler plugin allows you to view PDF, MS Office, iWork, RTF, TXT, and image files on a mobile device. If the Document Handler plugin is available, you can call the handleDocumentWithURL Document Handler plugin method to display a document. For example:

function showPDFDocument () {
    var docURL = '';
    var wObj = {};
    wObj.message = "Loading document, please wait...";


    try {
        var onLoadSuccess = function () {
            alert('Document loaded.');
        var onLoadFail = function () {
            alert('Document load failed.');

        handleDocumentWithURL(onLoadSuccess, onLoadFail, docURL);

    } catch (e) {

You can add the Document Handler plugin to your application in the Cordova Builder. Check the option for Document Handler under Third Party Plugins.

For more information on how to use the Document Handler plugin in your application, watch the following video: