Skip to content

This is a phonegap / cordova 3.3.0 plugin which converts the given html to a pdf document and stores it on the device.

License

Notifications You must be signed in to change notification settings

terrabythia/cordova-plugin-html2pdf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Html 2 Pdf

This is a pdf creation plugin for Phonegap 3.3.0 / Cordova 3.3.1 supporting Android (>=2.3.3) and iOS(>=6.0). It creates a pdf from the given html and stores it on the device.

There is one method:

  • create(html, filePath, successCallback, errorCallback)

Installation

You may use phonegap CLI as follows:

➜ phonegap local plugin add https://github.com/moderna/cordova-plugin-html2pdf.git
[phonegap] adding the plugin: https://github.com/moderna/cordova-plugin-html2pdf.git
[phonegap] successfully added the plugin

This Plugin requires iText.jar to be added to your project. Here is the last open source version (4.2.0) of it:

It has been confirmed to work with cordova 3.3.0+

Usage

document.addEventListener('deviceready', onDeviceReady);
function onDeviceReady()
{
        var success = function(status) {
            alert('Message: ' + status);
        }

        var error = function(status) {
            alert('Error: ' + status);
        }

        window.html2pdf.create(
            "<html><head></head><body><h1>Some</h1><p>html content.</p></body></html>",
            "~/Documents/test.pdf", // on iOS,
			// "test.pdf", on Android (will be stored in /mnt/sdcard/at.modalog.cordova.plugin.html2pdf/test.pdf)
            success,
            error
        );
}

About

This is a phonegap / cordova 3.3.0 plugin which converts the given html to a pdf document and stores it on the device.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 71.8%
  • Objective-C 26.7%
  • JavaScript 1.5%