im trying to print Html document on printer from my android device which is in same network as printer.
This is sample code im trying to use. Im only able to print raw html on printer.
Can someone help how to wrap that code to print html?
private String ipAdress, htmlContent;
private int port;
public PrintBon(String ipAdress,int port, String content) {
this.htmlContent = content;
this.ipAdress = ipAdress;
this.port = port;
}
public void print(){
try
{
Socket sock = new Socket(ipAdress, port);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
//prints raw htmlContent
oStream.println(htmlContent);
oStream.println("
");
//paper cut
oStream.write(0x1D);
oStream.write(86);
oStream.write(48);
oStream.write(0);
oStream.close();
sock.close();
}
catch(UnknownHostException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
question from:
https://stackoverflow.com/questions/65950556/android-print-html-document-on-printer-in-same-network 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…