0

I need to communicate a printer (zebra) with an api (php).

Example, you have a new data on the server, you must have a baton that checks this every 10 seconds, and send the file to the printer (the printer is on the computer).

But I have no idea how to do it, because I want to make it generic. I'm trying to use the electron, but it's not working. If anyone has any ideas, I'm grateful.

Federico Dipuma
  • 17,655
  • 4
  • 39
  • 56
Débora Gonçalves
  • 137
  • 1
  • 2
  • 10

1 Answers1

0

On Server

<?
$new="1.txt";
   if(file_exists($new)){
    exec('print /d:\\Network\printer1 c:\accounting\report.txt');
    echo "ok";
   }
?>

//on your PC

<script src="https://code.jquery.com/jquery-3.2.0.min.js"></script>
<button onclick="start()">Start printing...</button>
<script>
function start(){
    setInterval(function(){
$.ajax({
    url:"http://yourserver.ro/print.php", 
    type:"post", 
    data:({test:"test"}),
    success: function(rsp){ 
    if(rsp=="ok"){
        alert('printing...!')
    };
}});
},3000)}

</script>
Vitalicus
  • 1,188
  • 13
  • 15