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

cara/cordova-plugin-html2pdf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Html 2 Pdf

This is a pdf creation plugin for PCordova 6.1.1+ supporting Android (>4.1) 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

Packages

No packages published

Languages

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