Trying to print a png to ZQ520 from Cordova powered JavaScript file

T Thomas Murray 3 years 6 months ago
48 0 0

Hi guys, I am relatively new to mobile printing in general, so I would appreciate any help or advice.

If my title seems confusing, thats cause it is. Basically I am trying to develop a Bluetooth printing function to print a few images and some basic text but the catch is, I have no interface just a single Javascript file. The reason being, I am developing this feature in a third party app that allows me to create custom JS features. It is powered by Cordova and will run on Android.

So far I have been able to (relatively easily) print the basic text using the code below:

var addressLn1 = 'Company Name';
var addressLn2 = 'Street 1';
var addressLn3 = 'Street 2';
var addressLn4 = 'City';
var addressLn5 = 'County';
var addressLn6 = 'ZipCode';
var tel = 'Tel: 99999999'
var fax = 'Fax: 99999999'
var vat = 'VAT Reg No: xxxxxxxxxxxx'

var printCommand = "! 0 200 200 500 1" +
' |TEXT 5 3 350 40 INVOICE'+
' |TEXT 5 0 30 150 '+addressLn1+
' |TEXT 5 0 30 175 '+addressLn2+
' |TEXT 5 0 30 195 '+addressLn3+
' |TEXT 5 0 30 215 '+addressLn4+
' |TEXT 5 0 30 235 '+addressLn5+
' |TEXT 5 0 30 255 '+addressLn6+
' |TEXT 5 0 400 215 '+tel+
' |TEXT 5 0 400 235 '+fax+
' |TEXT 5 0 400 255 '+vat+
' |FORM ' +
'|PRINT ' + '|';

var stringtoPrint = GeopalPrint.getPrintString(printCommand); //converts the string to hex
GeopalPrint.printHex(stringtoPrint); //calls the printer and passes the bufferArray of hex

This prints nicely as expected, Invoice as a title then the address and contact details laid out underneath.

The problem I am having is I cannot seem to find a way to pass an image to the printer using CPCL, i have an image stored on the device (inside the third-party app) and i have said images file-path. The image is of format .png.

Does anyone have any experience in a similar scenario as me? I have trolled the internet and can only find examples of web or Android development.
**I do have a little leeway in the JS in that I can add a HTML page and install AngularJs if that will open any doors for me?

Any Help or advice would be very much appreciated!

Cheers,
Tom

CONTACT
Can’t find what you’re looking for?