How to: simulate an (IPP) printer

10.3k Views Asked by At

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. How can I simulate such a printer? Is there code for a dummy IPP printer?

I'll be working in either Linux or Windows.

3

There are 3 best solutions below

1
On

A fully-fledged, open source, IPP-2.2 and IPP Everywhere compliant printer simulator is the IPP Sample Software on Github. It is provided by the Printer Working Group (PWG), the body which standardized the IPP (Internet Printing Protocol).

The IPP Sample software can be compiled on any major platform: Linux, Windows, macOS.

The software is currently still in beta, but already very functional. One of the commandline tools it ships is 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. 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. You can use to test any (or your self-written) IPP client software against it.

IPP Sample ships a second important tool, ipptool. This can serve as an IPP client. You can play with both to test each other. See how that works in this ASCII-cast:

asciicast

If you want to try it yourself and you are on Linux, you do not even need to build it yourself. Simply use my read-made AppImage of the software (consisting of one single executable file), which can directly run without an "install" step. 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):

    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.)

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.)

  2. Validate printer's print-uri support:
    ./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.)

0
On

CUPS provides an IPP interface for printers. Using Java and jspi (as mentioned in this question; it's a bit outdated and needs some fixing, e.g. to accommodate resolution syntax for attributes) you may have the following code to access a local printer as an IPP printer:

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.

1
On

A very good IPP simulator is Apples Printer Simulator. Search for Printer Simulator at https://developer.apple.com/download/more/ (requires apple developer login) see this question) and download Additional Tools for Xcode.

Even though it's only available for OS X you can still test from Linux or Windows against this network service. Printed pages can pop up in Preview for review. The simulator also supports the required IPP attribute job-impressions-completed. The tool saves a lot of paper.

The CUPS server is not a perfect simulator. 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. This will result in real -not simulated- printing.

However CUPS also includes ippeveprinter which can be used to simulate an IPP Everywhere printer. "It can be used to test client software or act as a very basic print server that runs a command for every job that is printed."

ippeveprinter -f application/pdf -M IPP -m Everywhere MyEve