B4J Library B4j Print JavaFX8 + 17

stevel05

Expert
Licensed User
Longtime User
Example of using PrinterStatic.SearchPrinters:

B4X:
'    Search Printer Example

    Dim L As List = Printer_Static.SearchPrinters("PDF")
    

    If L.Size = 0 Then
        Log("Printer Not found")
    Else If L.Size > 1 Then


'        Could offer selection
'        Alternatively you could Select the first printer in the list
'        If you don't care which printer driver is used.

        Log("Multile Printers found")
        
    Else
        Dim P As Printer = L.Get(0)
        If Initialized(P) Then
            Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)
            PJ.GetJobSettings.SetOutputFile("D:\Test.pdf")
            PJ.PrintPage(ScaleOutput(P,MainForm.RootPane, True))
            PJ.PrintPage(lblTest)
            PJ.EndJob
        Else
            Log("Printer Not found")
        End If
    End If
 

Peter Simpson

Expert
Licensed User
Longtime User
Hmm,

I currently use the following to get all printers.
What I currently use:
    Dim Printers As List = Printer_Static.GetAllPrinters
    For Each P As Printer In Printers
        If P.GetName.StartsWith(PrinterName) Then Return P
    Next

OR

    'Printers
    For Each P As Printer In Printer_Static.GetAllPrinters
        CmbPrinters.Items.Add(P.GetName)
    Next
I then start printing documents.

I lean heavily on your library for all client projects, so the first thing that I'll do is to test your library and also xCharts if that has an updated.

Okay @stevel05, this is very nice indeed, thank you for the update

Cheers
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…