我已经准备好原始 ZPL 文件了,只是不知道如何设置要发送到的打印机,然后再发送。我该怎么做?
注意:我的计算机上有一个批处理脚本,我默认所有 ZPL 文件都使用它,这是一个将文件发送到我计算机上的热敏打印机的 shell 脚本。我想摆脱这种情况并在我的应用程序中拥有所有命令,这样我就不必使用这样的外部脚本。
这是我现在拥有的代码,当它运行时会使用我的批处理脚本自动打开:
Sub SaveLabel(ByRef labelFileName As String, ByRef labelBuffer() As Byte)
' Save label buffer to file
Dim myPrinter As New PrinterSettings
Dim LabelFile As FileStream = New FileStream(labelFileName, FileMode.Create)
LabelFile.Write(labelBuffer, 0, labelBuffer.Length)
LabelFile.Close()
' Display label
DisplayLabel(labelFileName)
End Sub
Sub DisplayLabel(ByRef labelFileName As String)
Dim info As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo(labelFileName)
info.UseShellExecute = True
info.Verb = "open"
info.WindowStyle = ProcessWindowStyle.Hidden
info.CreateNoWindow = True
System.Diagnostics.Process.Start(info)
End Sub
这是我的批处理脚本:
copy %1 \\%ComputerName%\Zebra