Send Raw Data to ZPL Printer using Visual Basic (MS Access 2000)

前端 未结 4 1018
生来不讨喜
生来不讨喜 2021-01-28 05:57

This is all that I can find, none of them work.

Option Compare Database Option Explicit

  Private Type DOCINFO
      pDocName As String
      pOutputFile         


        
相关标签:
4条回答
  • 2021-01-28 06:09

    My solution for Zebra

    1. Creating a generic/text printer in windows then sending to raw file to this printer
    2. In Zebra printers advanced settings --> others, there is a passthrough characters. You can send raw text with this to this printer.
    0 讨论(0)
  • 2021-01-28 06:14

    What I like to do is do something similar to your Method 2, but save it to a file (the raw printer data) and then do a file copy to the UNC path.

    file copy "C:\label.txt" \computername\sharename

    That works for me.

    0 讨论(0)
  • 2021-01-28 06:24

    Okay so this is how I managed to get thing this work. Not a best option as I wanted but ... it works.

    1) I use the same function, but written in C++, taken from here http://support.microsoft.com/kb/138594/EN-US

    // RawDataToPrinter - sends binary data directly to a printer
       // 
       // Params:
       //   szPrinterName - NULL terminated string specifying printer name
       //   lpData        - Pointer to raw data bytes
       //   dwCount       - Length of lpData in bytes
       // 
       // Returns: TRUE for success, FALSE for failure.
       // 
       BOOL RawDataToPrinter(LPSTR szPrinterName, LPBYTE lpData, DWORD dwCount)
       {
         HANDLE     hPrinter;
         DOC_INFO_1 DocInfo;
         DWORD      dwJob;
         DWORD      dwBytesWritten;
    
         // Need a handle to the printer.
         if( ! OpenPrinter( szPrinterName, &hPrinter, NULL ) )
           return FALSE;
    
         // Fill in the structure with info about this "document."
         DocInfo.pDocName = "My Document";
         DocInfo.pOutputFile = NULL;
         DocInfo.pDatatype = "RAW";
         // Inform the spooler the document is beginning.
         if( (dwJob = StartDocPrinter( hPrinter, 1, (LPSTR)&DocInfo )) == 0 )
         {
           ClosePrinter( hPrinter );
           return FALSE;
         }
         // Start a page.
         if( ! StartPagePrinter( hPrinter ) )
         {
           EndDocPrinter( hPrinter );
           ClosePrinter( hPrinter );
           return FALSE;
         }
         // Send the data to the printer.
         if( ! WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten ) )
         {
           EndPagePrinter( hPrinter );
           EndDocPrinter( hPrinter );
           ClosePrinter( hPrinter );
           return FALSE;
         }
         // End the page.
         if( ! EndPagePrinter( hPrinter ) )
         {
           EndDocPrinter( hPrinter );
           ClosePrinter( hPrinter );
           return FALSE;
         }
         // Inform the spooler that the document is ending.
         if( ! EndDocPrinter( hPrinter ) )
         {
           ClosePrinter( hPrinter );
           return FALSE;
         }
         // Tidy up the printer handle.
         ClosePrinter( hPrinter );
         // Check to see if correct number of bytes were written.
         if( dwBytesWritten != dwCount )
           return FALSE;
         return TRUE;
       }
    

    I got the file RAWPRN.EXE from there, put my EPL code in a txt file. Finally, use Shell to execute it

    Dim RetVal
    RetVal = Shell("cmd .exe /c C:\rawprint\RawPrint.exe ""ZDesigner LP 2844"" ""C:\eplcode.txt""", 1)
    
    0 讨论(0)
  • 2021-01-28 06:28

    if it is mapped to a parallel or com port, you can open that directly:

    open "LPT1:" For Output as #1
    ' or open "COM1:"
    print #1, "SomeData"
    Close #1
    
    0 讨论(0)
提交回复
热议问题