cordova-pdf-generator
Advanced tools
Comparing version 1.0.14 to 1.1.0
{ | ||
"name": "cordova-pdf-generator", | ||
"version": "1.0.14", | ||
"version": "1.1.00", | ||
"description": "is a HTML to PDF (offline) Generator.", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -10,3 +10,3 @@ # cordova-pdf-generator | ||
- Generates a PDF document using a URL or HTML. | ||
- Generates a PDF document using an URL, raw HTML text, HTMLElement and JQuery Element. | ||
- Open-with menu, open the context menu and (push to cloud, print, save, mail, etc...). | ||
@@ -13,0 +13,0 @@ - Return the Base64 file representation back, so you can upload the file to a server (IOS only). |
/*global cordova, module*/ | ||
function html_to_text(html) { | ||
if(typeof html === 'undefined') throw "undefined element, make sure the element is not empty."; | ||
var div = document.createElement('div') | ||
div.appendChild(html.cloneNode(true)); | ||
return div.innerHTML; | ||
} | ||
module.exports = { | ||
htmlToPDF: function (options, successCallback, errorCallback) { | ||
if(!options.url && !options.data) throw "No URL or HTML Data found."; | ||
var url = options.url; | ||
var data = options.data; | ||
var docSize = options.documentSize || "A4"; | ||
var landscape = options.landscape || "portrait"; | ||
var type = options.type || "base64"; | ||
var fileName = options.fileName || "default"; | ||
htmlToPDF: function(options, successCallback, errorCallback) { | ||
if (!options.url && !options.data) throw "No URL or HTML Data found."; | ||
if (options.data instanceof HTMLElement) { | ||
options.data = html_to_text(options.data); | ||
} | ||
cordova.exec(successCallback, errorCallback, "PDFService", "htmlToPDF", [ url, data, docSize, landscape, type, fileName ]); | ||
if(typeof options.data === 'object' && 'html' in options.data){ | ||
options.data = html_to_text(options.data[0]); | ||
} | ||
var url = options.url; | ||
var data = options.data; | ||
var docSize = options.documentSize || "A4"; | ||
var landscape = options.landscape || "portrait"; | ||
var type = options.type || "base64"; | ||
var fileName = options.fileName || "default"; | ||
cordova.exec(successCallback, errorCallback, "PDFService", "htmlToPDF", [url, data, docSize, landscape, type, fileName]); | ||
} | ||
}; |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
60957
193
1