I use a simple JS function for this. There is the first function that format text to display in HTML and the second that formats text for ZEBRA printing. I used CPCL in this example. But ZPL would work the same way.
function sDisplayText(left) {
var sResult = "
return sResult;
}
function sPrintText(left) {
var sResult = "T 7 0 30 30 " + left + '\r\n';
return sResult;
}
I assume that you get the content from a Database somewhere. You would have to use the function at the time you read the data and convert row by row:
Here is an example
var pStr = "";
var dStr = "";
pStr = pStr + sPrintText('My test row 1');
dStr = dStr + sDisplayText('My test row 1');
pStr = pStr + sPrintText('My test row 2');
dStr = dStr + sDisplayText('My test row 2');
This would result in:
dStr = "
pStr = "T 7 0 30 30 My test row 1\r\nT 7 0 30 30 My test row 2\r\n"
You can than take the content of "dStr" and display it on your browser and use "pStr" for the printer.
I would further suggest to use a plugin that understand ZEBRA and not just any print plugin.
Here is one that works with Android and Zebra