To apply cordova plugin printing for xod, you will have to edit printImages function in PrintModal.js. Below is the change that I made to PrintModal component:
isCordovaPrinter = () => {
return window.parent.cordova && window.parent.cordova.plugins.printer;
}
printImages = images => {
let printHandler;
if (this.isCordovaPrinter()) {
printHandler = document.createElement('div');
printHandler.style.display = 'block';
printHandler.style.height = '100%';
} else {
printHandler = document.getElementById('print-handler');
printHandler.innerHTML = '';
}
images.forEach((image, index) => {
if (this.isCordovaPrinter()) {
image.style.display = 'block';
image.style.maxWidth = '100%';
image.style.maxHeight = '100%';
image.style.width = '100%';
image.style.height = '100%';
image.style.objectFit = 'contain';
image.style.pageBreakAfter = 'always';
}
printHandler.appendChild(image);
});
if (this.isCordovaPrinter()) {
window.parent.cordova.plugins.printer.print(printHandler, 'Document.html');
} else {
window.print();
}
this.closePrintModal();
}
When I tested with the above code, I was able to get the print working, but there seemed to be some kind of margin in the first page.