简体   繁体   English

如何:模拟(IPP)打印机

[英]How to: simulate an (IPP) printer

I'd like to test out some features that IPP should have (namely, monitoring the number of impressions made; see this question ) but I haven't got the hardware yet. 我想测试IPP应该具备的一些功能(即,监控所做的印象次数;请参阅此问题 ),但我还没有得到硬件。 How can I simulate such a printer? 我该如何模拟这样的打印机? Is there code for a dummy IPP printer? 是否有虚拟IPP打印机的代码?

I'll be working in either Linux or Windows. 我将在Linux或Windows上工作。

A very good IPP simulator is Apples Printer Simulator . 一个非常好的IPP模拟器是苹果打印机模拟器 Look for Hardware IO Tools at https://developer.apple.com/download/more/ (see this question ) https://developer.apple.com/download/more/上查找硬件IO工具 (查看此问题

Even though it's only available for OS X you can still test from Linux or Windows against this network service. 即使它仅适用于OS X,您仍然可以针对此网络服务从Linux或Windows进行测试。 Printed pages can pop up in Preview for review. 打印页面可以在预览中弹出以供审阅。 The simulator also supports the required IPP attribute job-impressions-completed . 模拟器还支持所需的IPP属性job-impressions-completed The tool saves a lot of paper. 该工具可以节省大量纸张。

CUPS is not a good simulator. CUPS不是一个好的模拟器。 In order to work properly it needs a real printer it can print to. 为了正常工作,它需要一个可以打印到的真正的打印机。 You might pause a queue and test printing to it. 您可以暂停队列并测试打印。 You won't get any impressions-completed > 0 unless you release the queue. 除非您释放队列,否则不会获得任何impressions-completed > 0 This will result in real -not simulated- printing. 这将导致真实的 - 不是模拟印刷。

A fully-fledged, open source, IPP-2.2 and IPP Everywhere compliant printer simulator is the IPP Sample Software on Github. 完全成熟的开源IPP-2.2IPP Everywhere兼容的打印机模拟器是Github上的IPP示例软件 It is provided by the Printer Working Group (PWG), the body which standardized the IPP (Internet Printing Protocol). 它由打印机工作组 (PWG)提供,该工作组是标准化IPP(因特网打印协议)的机构。

The IPP Sample software can be compiled on any major platform: Linux, Windows, macOS. IPP Sample软件可以在任何主要平台上编译:Linux,Windows,macOS。

The software is currently still in beta, but already very functional. 该软件目前仍处于测试阶段,但已经非常实用。 One of the commandline tools it ships is ippserver . 它提供的命令行工具之一是ippserver This is the simulated printer you are looking for. 这是您正在寻找的模拟打印机。 It's much more powerful than Apples Printer Simulator -- but it does not have a GUI. 它比苹果打印机模拟器更强大 - 但它没有GUI。 You need to be familiar with running command line tools. 您需要熟悉运行命令行工具。

Once you can start ippserver (with the appropriate options) you'll have a fully-fledged virtual IPP printer instance on your network. 一旦你可以启动ippserver (使用适当的选项),你的网络上就会有一个完全成熟的虚拟IPP打印机实例。 You can use to test any (or your self-written) IPP client software against it. 您可以使用它来测试任何(或您自己编写的)IPP客户端软件。

IPP Sample ships a second important tool, ipptool . IPP Sample提供了第二个重要的工具, ipptool This can serve as an IPP client. 这可以作为IPP客户端。 You can play with both to test each other. 你可以玩两个来互相测试。 See how that works in this ASCII-cast: 看看这个ASCII转换如何工作:

asciicast

If you want to try it yourself and you are on Linux, you do not even need to build it yourself. 如果您想自己尝试并且使用Linux,那么您甚至不需要自己构建它。 Simply use my read-made AppImage of the software (consisting of one single executable file), which can directly run without an "install" step. 只需使用我所读取的软件AppImage (由一个可执行文件组成),它可以在没有“安装”步骤的情况下直接运行。 Here's how: 这是如何做:

  1. Download it: 下载它:

     wget https://github.com/KurtPfeifle/ippsample/releases/download/continuous/ippsample-x86_64.AppImage 
  2. Make AppImage executable (and optionally rename it to ippsample ): 使AppImage可执行 (并可选择将其重命名为ippsample ):

     chmod a+x ippsample-x86_64.AppImage mv ippsample-x86_64.AppImage ippsample 
  3. Have a look at its built-in help screen: 看看它内置的帮助屏幕:

     ./ippsample --ai-usage 
  4. Run it: 运行:

     ./ippsample ipptool -t -v ipp://xxx.xxx.xxx.xxx/ipp/print ipp-2.0.test 

    (This would run a test suite to validate complete IPP-2.0 compliance of the IPP printer on IP address xxx.xxx.xxx.xxx.) (这将运行一个测试套件,以验证IPP打印机在IP地址xxx.xxx.xxx.xxx上的完整IPP-2.0合规性。)

More test examples: 更多测试示例:

  1. Print a job: 打印工作:
    ./ippsample ipptool -t -v \\ -f my.pdf \\ ipp://xxx.xxx.xxx.xxx/ipp/print \\ print-job.test (This would print send my.pdf as a print job to the printer.) ./ippsample ipptool -t -v \\ -f my.pdf \\ ipp://xxx.xxx.xxx.xxx/ipp/print \\ print-job.test (这会打印发送my.pdf作为打印作业到打印机。)

  2. Validate printer's print-uri support: 验证打印机的print-uri支持:
    ./ippsample ipptool -t -v \\ -o document-uri=https://ftp.pwg.org/pub/pwg/candidates/cs-ippeve10-20130128-5100.14.pdf \\ ipp://xxx.xxx.xxx.xxx/ipp/print \\ print-uri.test

    (This would tell the printer to fetch named PDF from document-uri and print it.) (这会告诉打印机从document-uri获取命名的PDF并打印它。)

CUPS provides an IPP interface for printers. CUPS为打印机提供IPP接口。 Using Java and jspi ( as mentioned in this question ; it's a bit outdated and needs some fixing, eg to accommodate resolution syntax for attributes) you may have the following code to access a local printer as an IPP printer: 使用Java和jspi如本问题中所述 ;它有点过时,需要一些修复,例如,为了适应属性的解析语法),您可以使用以下代码作为IPP打印机访问本地打印机:

IppPrintService service = new IppPrintService(URI.create("ipp://localhost:631/printers/HL2240D-local"));

Also available is CUPS4J which I think does the same thing, but through its own interfaces and not through javax.print . 另外可用的是CUPS4J ,我认为它做同样的事情,但是通过它自己的接口而不是通过javax.print

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM