Results 1 to 3 of 3

Thread: Receipt Printer Recommendation?

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Receipt Printer Recommendation?

    Can anyone recommend a POS receipt printer that would integrate easily to a .NET WinForms application?

    Basically what I mean by integrate easily, is that the printer would actually show up as a standard windows printer, because the existing application uses Microsoft reporting services to print receipts, and I do not want to have to redo the entire receipt process via some SDK or API exposed by some proprietary receipt printer.

    Right now the client is printing on 8.5x11 sheets of paper from a standard printer, and it is just silly to use such big paper for receipts.

    We thought about getting half sized paper, since the current laser printer tray supports it, but found that non standard paper sizes run much more expensive than standard size paper, and it is not worth it.

    So I will tweak the report layout to fit a smaller size once I have a printer in place to use, so I am just looking for a recommendation if anyone has worked with any specific POS receipt printers.

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Receipt Printer Recommendation?

    There is a receipt printer I use at work that works just like a normal printer. We sometimes accidentally print regular 8.5 x 11 pages on to it :P

    I'll be sure to test it with a dummy app and see if it will work, but I'm pretty sure it will.

    I'll get the brand tomorrow and post it if you haven't already found something.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3
    New Member
    Join Date
    Sep 2009
    Location
    Columbia Mo
    Posts
    2

    Re: Receipt Printer Recommendation?

    I have worked with sevreal pos systems.
    Fav to work with and I think it would work for you is the WASP reciept printers.
    When you goto instll the printer install a Genral Text Printer
    Here is a class for the Wasp Printer

    vb Code:
    1. Imports System.IO
    2. Imports System.Drawing.Printing
    3. Imports System.Runtime.InteropServices
    4.  
    5. Public Class WASP
    6.     ' Structure and API declarions:
    7.     <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
    8.     Structure DOCINFOW
    9.         <MarshalAs(UnmanagedType.LPWStr)> Public pDocName As String
    10.         <MarshalAs(UnmanagedType.LPWStr)> Public pOutputFile As String
    11.         <MarshalAs(UnmanagedType.LPWStr)> Public pDataType As String
    12.     End Structure
    13.  
    14.     <DllImport("winspool.Drv", EntryPoint:="OpenPrinterW", _
    15.        SetLastError:=True, CharSet:=CharSet.Unicode, _
    16.        ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    17.     Public Shared Function OpenPrinter(ByVal src As String, ByRef hPrinter As IntPtr, ByVal pd As Long) As Boolean
    18.     End Function
    19.     <DllImport("winspool.Drv", EntryPoint:="ClosePrinter", _
    20.        SetLastError:=True, CharSet:=CharSet.Unicode, _
    21.        ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    22.     Public Shared Function ClosePrinter(ByVal hPrinter As IntPtr) As Boolean
    23.     End Function
    24.     <DllImport("winspool.Drv", EntryPoint:="StartDocPrinterW", _
    25.        SetLastError:=True, CharSet:=CharSet.Unicode, _
    26.        ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    27.     Public Shared Function StartDocPrinter(ByVal hPrinter As IntPtr, ByVal level As Int32, ByRef pDI As DOCINFOW) As Boolean
    28.     End Function
    29.     <DllImport("winspool.Drv", EntryPoint:="EndDocPrinter", _
    30.        SetLastError:=True, CharSet:=CharSet.Unicode, _
    31.        ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    32.     Public Shared Function EndDocPrinter(ByVal hPrinter As IntPtr) As Boolean
    33.     End Function
    34.     <DllImport("winspool.Drv", EntryPoint:="StartPagePrinter", _
    35.        SetLastError:=True, CharSet:=CharSet.Unicode, _
    36.        ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    37.     Public Shared Function StartPagePrinter(ByVal hPrinter As IntPtr) As Boolean
    38.     End Function
    39.     <DllImport("winspool.Drv", EntryPoint:="EndPagePrinter", _
    40.        SetLastError:=True, CharSet:=CharSet.Unicode, _
    41.        ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    42.     Public Shared Function EndPagePrinter(ByVal hPrinter As IntPtr) As Boolean
    43.     End Function
    44.     <DllImport("winspool.Drv", EntryPoint:="WritePrinter", _
    45.        SetLastError:=True, CharSet:=CharSet.Unicode, _
    46.        ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    47.     Public Shared Function WritePrinter(ByVal hPrinter As IntPtr, ByVal pBytes As IntPtr, ByVal dwCount As Int32, ByRef dwWritten As Int32) As Boolean
    48.     End Function
    49.  
    50.     ' SendBytesToPrinter()
    51.     ' When the function is given a printer name and an unmanaged array of  
    52.     ' bytes, the function sends those bytes to the print queue.
    53.     ' Returns True on success or False on failure.
    54.     Public Shared Function SendBytesToPrinter(ByVal szPrinterName As String, ByVal pBytes As IntPtr, ByVal dwCount As Int32) As Boolean
    55.         Dim hPrinter As IntPtr      ' The printer handle.
    56.         Dim dwError As Int32        ' Last error - in case there was trouble.
    57.         Dim di As DOCINFOW = Nothing          ' Describes your document (name, port, data type).
    58.         Dim dwWritten As Int32      ' The number of bytes written by WritePrinter().
    59.         Dim bSuccess As Boolean     ' Your success code.
    60.  
    61.         ' Set up the DOCINFO structure.
    62.         With di
    63.             .pDocName = "Open Cash Drawer"
    64.             .pDataType = "RAW"
    65.         End With
    66.         ' Assume failure unless you specifically succeed.
    67.         bSuccess = False
    68.         If OpenPrinter(szPrinterName, hPrinter, 0) Then
    69.             If StartDocPrinter(hPrinter, 1, di) Then
    70.                 If StartPagePrinter(hPrinter) Then
    71.                     ' Write your printer-specific bytes to the printer.
    72.                     bSuccess = WritePrinter(hPrinter, pBytes, dwCount, dwWritten)
    73.                     EndPagePrinter(hPrinter)
    74.                 End If
    75.                 EndDocPrinter(hPrinter)
    76.             End If
    77.             ClosePrinter(hPrinter)
    78.         End If
    79.         ' If you did not succeed, GetLastError may give more information
    80.         ' about why not.
    81.         If bSuccess = False Then
    82.             dwError = Marshal.GetLastWin32Error()
    83.         End If
    84.         Return bSuccess
    85.     End Function ' SendBytesToPrinter()
    86.  
    87.     ' SendFileToPrinter()
    88.     ' When the function is given a file name and a printer name,
    89.     ' the function reads the contents of the file and sends the
    90.     ' contents to the printer.
    91.     ' Presumes that the file contains printer-ready data.
    92.     ' Shows how to use the SendBytesToPrinter function.
    93.     ' Returns True on success or False on failure.
    94.     Public Shared Function SendFileToPrinter(ByVal szPrinterName As String, ByVal szFileName As String) As Boolean
    95.         ' Open the file.
    96.         Dim fs As New FileStream(szFileName, FileMode.Open)
    97.         ' Create a BinaryReader on the file.
    98.         Dim br As New BinaryReader(fs)
    99.         ' Dim an array of bytes large enough to hold the file's contents.
    100.         Dim bytes(fs.Length) As Byte
    101.         Dim bSuccess As Boolean
    102.         ' Your unmanaged pointer.
    103.         Dim pUnmanagedBytes As IntPtr
    104.  
    105.         ' Read the contents of the file into the array.
    106.         bytes = br.ReadBytes(fs.Length)
    107.         ' Allocate some unmanaged memory for those bytes.
    108.         pUnmanagedBytes = Marshal.AllocCoTaskMem(fs.Length)
    109.         ' Copy the managed byte array into the unmanaged array.
    110.         Marshal.Copy(bytes, 0, pUnmanagedBytes, fs.Length)
    111.         ' Send the unmanaged bytes to the printer.
    112.         bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, fs.Length)
    113.         ' Free the unmanaged memory that you allocated earlier.
    114.         Marshal.FreeCoTaskMem(pUnmanagedBytes)
    115.         Return bSuccess
    116.     End Function ' SendFileToPrinter()
    117.  
    118.     ' When the function is given a string and a printer name,
    119.     ' the function sends the string to the printer as raw bytes.
    120.     Public Shared Sub SendStringToPrinter(ByVal szPrinterName As String, ByVal szString As String, Optional ByVal NumberOfRePrinted As Integer = 1)
    121.         Dim pBytes As IntPtr
    122.         Dim dwCount As Int32
    123.         Dim i As Integer = 1
    124.         If NumberOfRePrinted = 1 Then
    125.             ' How many characters are in the string?
    126.             dwCount = szString.Length()
    127.             ' Assume that the printer is expecting ANSI text, and then convert
    128.             ' the string to ANSI text.
    129.             pBytes = Marshal.StringToCoTaskMemAnsi(szString)
    130.             ' Send the converted ANSI string to the printer.
    131.             SendBytesToPrinter(szPrinterName, pBytes, dwCount)
    132.             Marshal.FreeCoTaskMem(pBytes)
    133.         Else
    134.             Do Until i > NumberOfRePrinted
    135.                 ' How many characters are in the string?
    136.                 dwCount = szString.Length()
    137.                 ' Assume that the printer is expecting ANSI text, and then convert
    138.                 ' the string to ANSI text.
    139.                 pBytes = Marshal.StringToCoTaskMemAnsi(szString)
    140.                 ' Send the converted ANSI string to the printer.
    141.                 SendBytesToPrinter(szPrinterName, pBytes, dwCount)
    142.                 Marshal.FreeCoTaskMem(pBytes)
    143.                 i += 1
    144.             Loop
    145.         End If
    146.     End Sub
    147. End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width