Assalamu 'alaikum....... And Good Afternoon, sob !!!
Kali ini ane mau share Program pencetak yang mana output file yg diterima klien adalah sebagai berikut :
^XA
^FO250,20^ADN,110,50^FDINNER^FS
^FO40,120^ADN,30,15^FDPT SANGO CERAMICS INDONESIA^FS
^FO40,180^ADN,30,10^FDPEDIDO:^FS
^FO200,180^ADN,30,15^FD0077000274^FS
^FO40,230^ADN,30,10^FDMATERIAL:^FS
^FO200,230^ADN,30,10^FD000000000000027434^FS
^FO480,230^ADN,30,10^FDQTD:^FS
^FO530,230^ADN,30,10^FD 6^FS
^FO630,230^ADN,30,10^FDUN. MED:^FS
^FO730,230^ADN,30,10^FDINN^FS
^FO40,280^ADN,30,10^FDROYAL GARDEN PRATO RASO AZBR^FS
^FO40,340^BY2^BC,150,N,N,N^FD0077000274265032050000148217^FS
^FO120,500^ADN,30,10^FD(01)0077000274(02)26503(03)2050000148217^FS
^FO20,170^GB760,0,4^FS
^FO20,320^GB760,0,4^FS
^XZ
makanan apa juga , beliau juga kurang paham. sampailah info tersebut di meja ane.
yap!!! langsung aja ane langsung jelasin (versi ane gan) --> ini adalah print to file dari aplikasi/program pencetak barcode yang mana printer menggunakan merk "Zebra" . #wisngunutok
Jika diprint lansung tanpa script maka akan didapat hasil seperti dibawah ini :
maka untuk menghasilkan hasil printout yg sama / dicetak di klient maka kita harus menginstall Printer Generic text only , dengan syarat menggunakan Port LPT atau COM ...
naaah...... berhubung komputer jaman sekarang terlalu jadul untuk port LPT atau COM , dan Port USB menjadi andalan unutk era sekarang ini, maka kita harus ngakali dengan script yang telah dibuat terlebih dahulu. like this brow !!! :
Option Explicit
Private Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, ByVal pDefault As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pDocInfo As DOCINFO) As Long
Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, pcWritten As Long) As Long
Public Sub GSN_Print(NamaFile As String, DataPrint As String)
Dim lhPrinter As Long
Dim lReturn As Long
Dim lpcWritten As Long
Dim lDoc As Long
Dim sWrittenData As String
Dim MyDocInfo As DOCINFO
lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
If lReturn = 0 Then
MsgBox "Printer tidak dikenali!", vbCritical, "Error"
Exit Sub
End If
MyDocInfo.pDocName = NamaFile
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = "RAW"
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)
sWrittenData = vbCrLf & DataPrint & vbCrLf
' vbFormFeed
lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
End Sub
Hasil compile dapat disedot
dimari
Semoga Bermanfaat