This plugin allows for printing from the browser.
This demo is using the cordova-plugin-printer plugin. For more information click here:
var GSW = GSW || {};
GSW.Tests = GSW.Tests || {};
GSW.Tests.onDeviceReady = function() {
// Cordova is now initialized. Have fun!
console.log('Now running cordova-' + cordova.platformId + '@' + cordova.version);
GSW.Tests.print = function() {
let text = document.getElementById("user-input").value;
cordova.plugins.printer.print(text);
}
GSW.Tests.printPage = function() {
cordova.plugins.printer.print();
}
// PRINTING OTHER ITEMS
// PLAIN TEXT : cordova.plugins.printer.print("Hello\nWorld!");
// HTML & CSS : cordova.plugins.printer.print('Hello World!
');
// IMAGES/PDFS/OTHER DOCUMENTS: cordova.plugins.printer.print('file://img/logo.png');
// BASE64 ENCODED CONTENT : cordova.plugins.printer.print('base64://...');
document.getElementById("print").addEventListener("click", GSW.Tests.print);
document.getElementById("printPage").addEventListener("click", GSW.Tests.printPage);
}
document.addEventListener('deviceready', GSW.Tests.onDeviceReady, false);