B4J Question B4j Print JavaFX8 - set printer by name

jroriz

Active Member
Licensed User
How can i set the printer by name using library Print JavaFX8?
 

stevel05

Expert
Licensed User
You can use this sub:

B4X:
Private Sub GetPrinter(Name As String) As Printer
    Dim Printers As List = Printer_Static.GetAllPrinters
    For Each P As Printer In Printers
        If P.GetName.StartsWith(Name) Then Return P
    Next
    Return Null
End Sub

And call using:
B4X:
    Dim P As Printer = GetPrinter("Foxit")
    If P <> Null And P.IsInitialized Then
        Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)
        PJ.PrintPage(Pane1)
        PJ.EndJob
    Else
        Log("Printer not found")
    End If
 
Upvote 0

jroriz

Active Member
Licensed User
You can use this sub:

B4X:
Private Sub GetPrinter(Name As String) As Printer
    Dim Printers As List = Printer_Static.GetAllPrinters
    For Each P As Printer In Printers
        If P.GetName.StartsWith(Name) Then Return P
    Next
    Return Null
End Sub

And call using:
B4X:
    Dim P As Printer = GetPrinter("Foxit")
    If P <> Null And P.IsInitialized Then
        Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)
        PJ.PrintPage(Pane1)
        PJ.EndJob
    Else
        Log("Printer not found")
    End If

£ 2.00 in your pocket ....
I know it's not much, but if everyone did it ...
Thank you.
 
Upvote 0
Top