I want to code an Android app, which will connect to a network printer with a specific IP address, and then make a printing.
For printing I know that I need to write my own Postscript for specific files types, and connecting to a network is not a problem over WIFI.
How to connect to the network printer?
Check the printer connection status: Make sure the wireless signal is on, and the printer is connected to the same network as your computer or mobile device. If your printer has a light next to a Wireless icon or button , make sure the light is on. If it is off or blinks the printer is disconnected from the network.
You can also print directly from your open documents, like with Android, if your smartphone and printer are connected to the same wi-fi network. To print from a Windows tablet, swipe to the left to bring up the Charms bar and then select Devices.
Any device connected to a network will communicate via their IP and Ports / sockets. The simplest way to connect via telnet or socket and write the data to their socket buffers.
try
{
Socket sock = new Socket("192.168.1.222", 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.println("HI,test from Android Device");
oStream.println("\n\n\n");
oStream.close();
sock.close();
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
You might be able to use lpdspooler, that is, if the printer supports LPR/LPD. If you can give some more details about the environment (printer, etc), I might be able to give more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With