I am developing a desktop application using php
and javascript
. I need to print the image and data of a person who enters the premises using the printer Zebra GC420t printer.
The problem I am facing is - for example lets say A is entering to the premises I take details from him and print the data and his image. When B enters the premises when I try to print the data of B's is printed properly but the image printed is A's image and again I need to give the print to print the B's image.
So this is what happens to my application. Is there any solution to overcome this problem
I referred this php code that RGB image converting to grf image and the below javascript
code to send the data to the printer
function sendData(photoURL)
{
var test;
$.ajax({
url: 'db/zpl.php?photo='+photoURL,
cache: false,
contentType: false,
processData: false,
type: 'GET',
success: function(data) {
test=data;
console.log("From ZPL:"+data);
}
});
var mob="",lap="",other="";
if($("#emobile").val()==="on"){
mob="Mobile";
}
if($("#elaptop").val()==="on"){
lap="Laptop";
}
if($("#eother").val()==="on"){
other="Other";
}
showLoading("Printing...");
checkPrinterStatus( function (text){
if (text == "Ready to Print")
{
selected_printer.send("^XA N ^XZ");
selected_printer.send("~DYE:SAMPLE.GRF,A,GRF,5000,030"+test+",A");
selected_printer.send("^XA^FX ^CFA,30 ^FO100,50^FDVisitor Name:"+$("#user").val()+"^FS ^FO50,80^FDCompany:"+$("#compName").val()+"^FS ^FO50,110^FDTo Meet:"+$("#toMeet").val()+"^FS ^FO50,150^FDPurpose:"+$("#reason").val()+"^FS ^FO50,190^FDAuthorise^FS ^FO50,220^FDto Carry:"+mob+" "+lap+"^FS ^FO500,70^XG R:SAMPLE.GRF,1,1^FS^XZ");
}
else
{
printerError(text);
}
});
};
The above is the javascript
function which takes the image from the php
code and send it the function and selected_printer.send()
is responsible for sending the data to the printer
function registration(){
var data = new FormData(document.getElementById("registration"));
$.ajax({
url: 'db/registration.php',
data: data,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function(data) {
console.log("registration URL: "+data);
sendData(data);
}
});
The sendData()
is called in the above function