October 22, 2024
Chicago 12, Melborne City, USA
PHP

Printing paper on the clients available printers within thier network Codeigniter PHP


the probllem in question is that there needs to be made a print job to an printer that is not on the local network of the site and the only thing you know of the printer is its ip address. therefore you cant use commands to fix the problem. i would love it if it can be written in pure php together with codeigniter but if an api can help so be it.

attempt
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

if ($socket === false) {
    die("Failed to create socket: " . socket_strerror(socket_last_error()));
}

// Connect to the printer
$result = socket_connect($socket, $printer_ip, 9100);

if ($result === false) {
    die("Failed to connect to printer: " . socket_strerror(socket_last_error($socket)));
}

// Send the data to the printer
socket_write($socket, $file, strlen($file));

// Close the socket
socket_close($socket);

i treid using commands websockets CURL and an outdated google api and looked at alot of diffrent other apis that would od the smae but it is still mostly for local networks or you cant axactly print a piece of papper with it.

i know this isnt the best way to ask questions but i am realy at a los here searched for 20 hours and tried alot of diffrent ways. but this might be impossible what i hope isnt so. every comment and answer is welcome. and i wil try to make the question more clear if it wasnt



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video