I’m trying to print a DIV (Form) , but on the iOS version it seems to be ignoring the stylesheet / css.
“page” is the element which I print with the cordova print plugin, however on iOS the layout is all messed up. I’ve also tried
page = document.getElementById(“Form2”) but again no css or style.
Below works perfectly on android:
var page = document.documentElement.innerHTML = prints the current screen on Android, iOS only Prints Form1
SOLVED: Finally after days of trial and error this works,
How to print a DIV or Form on iOS using the de.appplant.cordova.plugin.printer plugin:
PrintButton_onclick()
If (navigator.userAgent.match(/(ios|iPhone|iPod|iPad)/)) Then
var PrintHead = document.head
var PrintBody = document.getElementById("Form1")
page = PrintHead.innerHTML + PrintBody.innerHTML
JavaScript
cordova.plugins.printer.print(page, 'DocumentName', function () {
NSB.MsgBox("Printing finished or was cancelled.","Ok","Alert")
});
End JavaScript
End if
End Function
Notes:
DocumentName = Can be any name you want, iOS will use this name if you save as PDF.
Form1 = Can be any of your forms or a specific DIV id.