Buenas tardes,
He generado un pdf de un tiquet y lo quiero imprimir a una impresora portátil (BIXOLON SPP-R210) conectada vía Bluetooth.
He realizado la siguiente prueba (código adjunto) y me conecto correctamente a la impresora pero no se como enviar el documento pdf del tiquet que he generado anteriormente. El código que está en rojo no realiza niguna impresión.
Sub Process_Globals
Dim Serial1 As Serial
Dim TextReader1 As TextReader
Dim TextWriter1 As TextWriter
Dim Timer1 As Timer
Dim connected As Boolean
Dim PDFjetPDF1 As PDFjetPDF
Dim PDFDestination As OutputStream
End Sub
Sub Globals
Dim btnSend As Button
Dim txtLog As EditText
Dim txtSend As EditText
Private Button1 As Button
Private Button2 As Button
Private Button3 As Button
End Sub
Sub Activity_Create (FirstTime As Boolean)
If FirstTime Then
Serial1.Initialize ( "Serial1")
Timer1.Initialize ( "Timer1", 200)
End If
Activity .LoadLayout ( "1")
End Sub
Sub Activity_Resume
If Serial1.IsEnabled = False Then
Msgbox ( "Activar el BlueTooth.", "")
Else
Serial1.Listen
End If
End Sub
Sub Button1_Click
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add (PairedDevices.GetKeyAt (i))
Next
Dim res As Int
res = InputList (l, "Seleccionar un dispositivo", - 1)
If res <> DialogResponse .CANCEL Then
Msgbox(PairedDevices.Get (l.Get (res)),"aqui")
Serial1.Connect (PairedDevices.Get (l.Get (res)))
End If
End Sub
Sub Serial1_Connected (Success As Boolean)
If Success Then
ToastMessageShow ( "Connected successfully", False)
connected = True
Else
connected = False
Msgbox (LastException .message, "Error connecting.")
End If
End Sub
Sub Button2_Click
Serial1.Disconnect
connected = False
End Sub
Sub Button3_Click
If connected Then
If File.Exists(File.DirRootExternal & "/" & "documentos/tiquets/","990001.pdf") Then
PDFDestination=File.OpenOutput(File.DirRootExternal & "/" & "documentos/tiquets/", "990001.pdf", False)
PDFjetPDF1.Initialize("PDFjetPDF1", PDFDestination)
PDFjetPDF1.Flush
End If
'TextWriter1.WriteLine (txtSend.Text)
'TextWriter1.Flush
'txtSend.Text = ""
End If
End Sub
Sub Timer1_Tick
If connected Then
If TextReader1.Ready Then
txtLog.Text = txtLog.Text & TextReader1.ReadLine & CRLF
txtLog.SelectionStart = txtLog.Text.Length
End If
End If
End Sub
He generado un pdf de un tiquet y lo quiero imprimir a una impresora portátil (BIXOLON SPP-R210) conectada vía Bluetooth.
He realizado la siguiente prueba (código adjunto) y me conecto correctamente a la impresora pero no se como enviar el documento pdf del tiquet que he generado anteriormente. El código que está en rojo no realiza niguna impresión.
Sub Process_Globals
Dim Serial1 As Serial
Dim TextReader1 As TextReader
Dim TextWriter1 As TextWriter
Dim Timer1 As Timer
Dim connected As Boolean
Dim PDFjetPDF1 As PDFjetPDF
Dim PDFDestination As OutputStream
End Sub
Sub Globals
Dim btnSend As Button
Dim txtLog As EditText
Dim txtSend As EditText
Private Button1 As Button
Private Button2 As Button
Private Button3 As Button
End Sub
Sub Activity_Create (FirstTime As Boolean)
If FirstTime Then
Serial1.Initialize ( "Serial1")
Timer1.Initialize ( "Timer1", 200)
End If
Activity .LoadLayout ( "1")
End Sub
Sub Activity_Resume
If Serial1.IsEnabled = False Then
Msgbox ( "Activar el BlueTooth.", "")
Else
Serial1.Listen
End If
End Sub
Sub Button1_Click
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add (PairedDevices.GetKeyAt (i))
Next
Dim res As Int
res = InputList (l, "Seleccionar un dispositivo", - 1)
If res <> DialogResponse .CANCEL Then
Msgbox(PairedDevices.Get (l.Get (res)),"aqui")
Serial1.Connect (PairedDevices.Get (l.Get (res)))
End If
End Sub
Sub Serial1_Connected (Success As Boolean)
If Success Then
ToastMessageShow ( "Connected successfully", False)
connected = True
Else
connected = False
Msgbox (LastException .message, "Error connecting.")
End If
End Sub
Sub Button2_Click
Serial1.Disconnect
connected = False
End Sub
Sub Button3_Click
If connected Then
If File.Exists(File.DirRootExternal & "/" & "documentos/tiquets/","990001.pdf") Then
PDFDestination=File.OpenOutput(File.DirRootExternal & "/" & "documentos/tiquets/", "990001.pdf", False)
PDFjetPDF1.Initialize("PDFjetPDF1", PDFDestination)
PDFjetPDF1.Flush
End If
'TextWriter1.WriteLine (txtSend.Text)
'TextWriter1.Flush
'txtSend.Text = ""
End If
End Sub
Sub Timer1_Tick
If connected Then
If TextReader1.Ready Then
txtLog.Text = txtLog.Text & TextReader1.ReadLine & CRLF
txtLog.SelectionStart = txtLog.Text.Length
End If
End If
End Sub