0

I want to send a print job to Cups and the printer is connected to CUPS via socket. I am looking for a solution for my Java program to send print jobs to the printer using a URL to CUPS.

CUPS: http://CUPS-IP-ADDRESS:631/

Printer: socket://PRINTER-IP-ADDRESS:PORT

I tried a few packages to send print jobs to the printer. But nothing works. I think the problem is that all packages want an IPP printer, but the printer can't use IPP. Also, the printer can't print PDFs. That's why I need CUPS to do it.

Packages I tried:

ipp-client

<dependency>
 <groupId>de.gmuth</groupId>
 <artifactId>ipp-client</artifactId>
 <version>3.2</version>
</dependency>

cups4j

<dependency>
 <groupId>org.cups4j</groupId>
 <artifactId>cups4j</artifactId>
 <version>0.7.9</version>
</dependency>

j4cups

<dependency>
 <groupId>de.javatux</groupId>
 <artifactId>j4cups</artifactId>
 <version>0.6.1</version>
</dependency>

For some reason, my printer cannot be found by the Java packages, especially printers that are registered as IPP and have IPP as a feature.

I have CUPS in a Docker container, so I need the CUPS-IP-ADDRESS for CUPS. When I use the CMD-Line lp -d MyPrinter srv/MyFile.pdf, the print job prints correctly.

If I use a CMD-Line to send a raw-file via telnet,curl -v --upload-file srv/MyFile.raw-file telnet://PRINTER-IP-ADDRESS:PORT, that also works. So I would expect that Java's socket class would do the same thing correctly with raw-files.

But I want to do it with PDFs because the raw-files are complicated to create and PDFs are much easier. So can someone help me send a print job to CUPS for my socket-connected printer? I couldn't find any documentation on this, only for IPP printers. It shouldn't be that hard to send a print job to CUPS via an URL, but I haven't found out how to do it yet.

asked Feb 10, 2025 at 10:13
2
  • I doubt you need any CUPS-specific packages. You need to google on Streaming print service Java Commented Feb 10, 2025 at 10:57
  • These packages are CUPS-specific. And I can print PDFs with CUPS because CUPS sends the correct format (pdf -> raw format) to the printer. But I can only print it via the command line, not with a URL to CUPS, because I don't know how. Commented Feb 10, 2025 at 11:06

1 Answer 1

0

I solved it.

My problem was that the printer I had registered in CUPS was not authorized for external commands. The only thing I had to do was set the property printer-is-shared to true to authorize the printer.

First check the MyPrinter options in CUPS: lpoptions -p MyPrinter

Then change the option: lpadmin -p MyPrinter -o printer-is-shared=true

Finally, restart the CUPS server

answered Mar 10, 2025 at 9:08
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.