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