Giter VIP home page Giter VIP logo

Comments (9)

harwey avatar harwey commented on September 24, 2024 1

The current SNAPSHOT version has a method

public boolean isPrinterClass()

on CupsPrinter class in order to ease use of printer classes.

from cups4j.

harwey avatar harwey commented on September 24, 2024

Hi Shambarick,

Printer classes are not supported (yet).
Cups4j mainly aims to query printers on CUPS-Servers, print documents and check job state in order to be able to signal problems or success of print jobs to applications an users. Cups4J mainly supports IPP-Operations and only some CUPS extensions so far.

As I understand printer classes are more a feature to organize printers in groups than a key feature used for printing.

Can you describe what you want to do with it in your application? This should make it more transparent, what changes in Cups4j are needed to support classes for you.

from cups4j.

shambarick avatar shambarick commented on September 24, 2024

I have several printers for different specific needs: ID card, license, ...
So when I have to print an ID card, I would just create a printing job to the class "ID Card", and one of the available printers of the class would print it. Also, if I add more printers or replace them, it won't affect the application, since the only thing it needs to know is the class to use for printing.

from cups4j.

harwey avatar harwey commented on September 24, 2024

That sounds interesting and might be of good use for others too. I will take a look at this and will come back to this thread.

from cups4j.

harwey avatar harwey commented on September 24, 2024

So, cups4j supports printer classes already out of the box.
Say you have a class of printers called "test" on your CUPS server on localhost and a pdf file in /tmp/test.pdf that should be printed.

CupsClient client = new CupsClient(host, port);
CupsPrinter printer = client.getPrinter(new URL("http://localhost:631/classes/test"));
PrintJob printJob = new PrintJob.Builder(new FileInputStream(new File("/tmp/test.pdf"))).build();
printer.print(printJob);

Please check if this works in your scenario.

from cups4j.

shambarick avatar shambarick commented on September 24, 2024

Thanks, just tested it, and it seems to work great.
Now I'm looking for how to get the list of classes. I didn't find how to get it with cups4j. I plan to have an API to expose the available classes, so the clients know which ones to use.

from cups4j.

harwey avatar harwey commented on September 24, 2024

Printer classes contain "classes" in their CUPS URL.
You can find your classes this way:

CupsClient client = new CupsClient(host, port);
Map<String, CupsPrinter> classMap=new HashMap<String, CupsPrinter>();
       
for(CupsPrinter printer: client.getPrinters()) {
  if(printer.getPrinterURL().toString().contains("classes")) {
     classMap.put(printer.getName(),printer);
  }
}

from cups4j.

shambarick avatar shambarick commented on September 24, 2024

Thanks, I didn't notice that part. Actually the library already supports what I need 😄

from cups4j.

shambarick avatar shambarick commented on September 24, 2024

Thank you for the update.

from cups4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.