'Issue: Zebra printer print label with previous data
I'm new to Zebra printers and still learning about ZPL. I need help on printing label using USB Connection from VB.net to GK420t printer.
^XA
^CF0,30,28^FO110,23^FD{Hello}^FS
^CF0,24,26^FO110,58^FD{World}^FS
^XZ
Public Function GetUSBPrinters() As List(Of DiscoveredPrinter)
Dim printerList As List(Of DiscoveredPrinter) = New List(Of DiscoveredPrinter)()
Try
For Each usbPrinter As DiscoveredUsbPrinter In UsbDiscoverer.GetZebraUsbPrinters()
printerList.Add(usbPrinter)
Console.WriteLine(usbPrinter)
Next
Catch e As ConnectionException
Console.WriteLine($"Error discovering local printers: {e.Message}")
End Try
Console.WriteLine("Done discovering local printers.")
Return printerList
End Function
Public Sub SendDataToPrinter()
zplcode = zplcode.Replace("{Hello}", "Hello")
zplcode = zplcode.Replace("{World}", "World")
Try
Dim printerList As List(Of DiscoveredPrinter) = GetUSBPrinters()
If printerList.Count > 0 Then
Dim discoveredPrinter As DiscoveredPrinter = printerList(0)
Dim connection As Connection = discoveredPrinter.GetConnection()
connection.Open()
connection.Write(Encoding.UTF8.GetBytes(zplcode))
End If
Catch ex As Exception
Console.WriteLine("No Printers found to print to.")
End Try
End Sub
The scenario would be like this: When I first time print Label A, it comes out one Label A. But when I try to print another label which is Label B, it will be printed Label B and Label A. And the cycle goes again.
Is there any solutions or anyone experiences these? Thanks in advance.
Solution 1:[1]
Besides the good answer provided by @Peter Leimbigler, as an alternative solution, converting the Date column to a string before applying the Style prevents the Styler formatter from adding timestamp.
df['Date'] = df['Date'].astype(str)
Using Peter's example:
# Example data
df = pd.DataFrame({'Date': pd.date_range('2020-01-01',
'2020-01-05',
freq='d'),
'Value': list(range(-2, 3))})
# Example color function
def f(v):
return 'color: red;' if v < 0 else None
# Converting the Date column to a string before applying the Style
df['Date'] = df['Date'].astype(str)
df.style.applymap(f, subset='Value')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Samwise |

