我正在开发一个要集成打印功能的应用程序。是否可以从该应用程序将文件发送到打印机(对于任何公司或品牌),然后进行打印。
到目前为止,谷歌搜索并发现以下代码,但没有运气。
try {
client = new Socket(ipAddress, port);
// create a byte array to file
byte[] mybytearray = new byte[(int) file.length()];
fileInputStream = new FileInputStream(file);
bufferedInputStream = new BufferedInputStream(fileInputStream);
// read the file
bufferedInputStream.read(mybytearray, 0, mybytearray.length);
outputStream = client.getOutputStream();
// write file to the output stream byte by byte
outputStream.write(mybytearray, 0, mybytearray.length);
outputStream.flush();
bufferedInputStream.close();
outputStream.close();
client.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
注意:我不想使用Google云打印。任何帮助将不胜感激。谢谢。
最佳答案
您可能可以使用lpdspooler http://lpdspooler.sourceforge.net/,即打印机是否支持LPR/LPD。如果您可以提供有关环境(打印机等)的更多详细信息。
关于android - 将android设备与打印机连接并打印文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20606316/