Exc*_*ion 6 printing android ipp-protocol
我的要求是在不使用任何基于云的服务的情况下从Android设备打印文件.
我已经能够使用"Raw"打印协议实现它,即只需将文件发送到端口9100的打印机IP地址即可.以下是代码段:
client = new Socket(ip,port); //Port is 9100
byte[] mybytearray = new byte[(int) file.length()]; //create a byte array to file
fileInputStream = new FileInputStream(file);
bufferedInputStream = new BufferedInputStream(fileInputStream);
bufferedInputStream.read(mybytearray, 0, mybytearray.length); //read the file
outputStream = client.getOutputStream();
outputStream.write(mybytearray, 0, mybytearray.length); //write file to the output stream byte by byte
outputStream.flush();
bufferedInputStream.close();
outputStream.close();
Run Code Online (Sandbox Code Playgroud)
"原始"打印协议的问题在于无法从打印机返回状态.
因此,我最近阅读了有关IPP和LDR的信息,我们可以使用它从打印机获取状态.
我试图找到一种方法来使用android实现它们但没有成功.我已经完成了这个答案,但没有找到我的解决方案.
如果有人可以指导我如何在android中实现IPP或LDR,那将会非常有帮助.
提前致谢!
IPP的一般用法:
您还应该检查其他最终作业状态:中止或取消
对于原型设计,您可以使用 ipptool(本机用于桌面使用):
# ipptool -t -d job=482 ipp://192.168.2.113/ipp job.ipp
{
OPERATION Get-Job-Attributes
GROUP operation-attributes-tag
ATTR charset attributes-charset utf-8
ATTR language attributes-natural-language en
ATTR uri printer-uri $uri
ATTR integer job-id $job
}
Run Code Online (Sandbox Code Playgroud)
更新 5/2020
我已经发布了 ipp 协议的 kotlin 实现。
https://github.com/gmuth/ipp-client-kotlin
提交后,您可以等待打印作业终止:job.waitForTermination()
| 归档时间: |
|
| 查看次数: |
8612 次 |
| 最近记录: |