Hi. I can get a list of all installed printers using this instruction Printer_Static.GetAllPrinters. But all the examples I've found in the forums only use the default printer or the dialog. I want to print either the content of a text file or a list using jFX8Print. I tried to use Printer_Static.MappedPrinter instruction but it errors. If I use the dialog with the list it errors too. Not sure what I'm doing wrong. The error using dialog is:
The error using MappedPrinter is:
Here is the code:
B4X:
java.lang.RuntimeException: Method: printPage not matched.
B4X:
java.lang.NullPointerException
Here is the code:
B4X:
Dim orderList As List
orderList.Initialize
If ModMain.APP_LANGUAGE = "Spanish" Then
orderList.add("Nombre: " & ord.CNameh)
orderList.Add( "Teléfono: " & ord.PNumb)
orderList.add("Fecha: " & ord.ODate & " " & ord.OTime)
Else
orderList.Add("Name: " & ord.CNameH)
orderList.Add("Phone: " & ord.PNumb)
orderList.Add("Date: " & ord.ODate & " " & ord.OTime)
End If
orderList.Add("---" & ord.OType & "---")
orderList.Add(" ")
For i = 0 To ordC.RowCount - 1
Dim currItm As String = ""
Dim currQty As Int
currItm = rs.GetString("Item")
currQty = rs.GetInt("Quantity")
orderList.Add(currQty & " - " & currItm)
Next
File.WriteList(ModMain.APP_PATH, ModMain.CURR_DB_NAME & ".txt", orderList)
' Dim writer As TextWriter
' writer.Initialize(File.OpenOutput(ModMain.APP_PATH, ModMain.CURR_DB_NAME & ".txt", False))
'
' For j = 0 To orderList.Size - 1
' writer.WriteLine(orderList.Get(j))
' Next
'
' writer.close
If ModMain.SELECTED_PRINTER <> "" Then
Dim p As Printer = Printer_Static.MappedPrinter(ModMain.SELECTED_PRINTER)
Dim pj As PrinterJob = PrinterJob_Static.CreatePrinterJob2(p)
pj.PrintPage(orderList)
pj.EndJob
Else
Dim pj As PrinterJob = PrinterJob_Static.CreatePrinterJob
pj.ShowPageSetupDialog(Null)
pj.ShowPrintDialog(Null)
pj.PrintPage(orderList)
pj.EndJob
End If