I have an application running on the server and I want to be able to detect the printers that are accessible from an xs computer.
That is, on the client side I want the printers to be listed and now, as the application is running from a server, it shows me the printers that are accessible from the server.
The idea is that from where you are going to access the application, or from a computer xs, you can list their respective printers.
I do not know if a path can be obtained by the IP address of that computer but I really could not find a way to solve it with what I have been doing this:
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
List <String> Impresoras= new ArrayList<>();
// -- ver los atributos de las impresoras...
for (PrintService printService : services) {
Impresoras.add(printService.getName());
System.out.println(" ---- IMPRESORA: " + printService.getName());
PrintServiceAttributeSet printServiceAttributeSet = printService.getAttributes();
System.out.println("--- atributos");
// todos los atributos de la impresora
Attribute[] a = printServiceAttributeSet.toArray();
for (Attribute unAtribute : a) {
System.out.println("atributo: " + unAtribute.getName());
}
System.out.println("--- viendo valores especificos de los atributos ");
// valor especifico de un determinado atributo de la impresora
System.out.println("PrinterLocation: " + printServiceAttributeSet.get(PrinterLocation.class));
System.out.println("PrinterInfo: " + printServiceAttributeSet.get(PrinterInfo.class));
System.out.println("PrinterState: " + printServiceAttributeSet.get(PrinterState.class));
System.out.println("Destination: " + printServiceAttributeSet.get(Destination.class));
System.out.println("PrinterMakeAndModel: " + printServiceAttributeSet.get(PrinterMakeAndModel.class));
System.out.println("PrinterIsAcceptingJobs: " + printServiceAttributeSet.get(PrinterIsAcceptingJobs.class));
Here I get the service that lists the printers but this does where the application runs.
If you could give me a clue, I'd really appreciate it, because I do not know much about Java and I'm testing with examples.
Greetings!