B4J Question Paper GetName error

hanyelmehy

Active Member
Licensed User
Longtime User
i use this code
B4X:
Dim P As Printer = Printer_Static.GetDefaultPrinter
    Log(P.GetName)
    
    For Each PP As JavaObject In P.GetPrinterAttributes.GetSupportedPapers
        Dim PPP As Paper
        PPP.Initialize
        PPP.SetObject(PP)
        Log(PPP.ToString)
        Log(PPP.GetName)
    Next
PPP.GetName show error java.lang.RuntimeException: Method: getName not found
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
This will do the trick:
Log all Window Printers:
#if java
import javax.print.PrintService;
import javax.print.PrintServiceLookup;

    public static void ShowPrinters() {
        PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
        System.out.println("Available printers:");
        for (PrintService printer : printServices) {
            System.out.println(printer.getName());
        }
    }
#end If
 
Upvote 0
Top