locked
POS Bill Printing using OPOS RRS feed

  • Question

  • Hi All,

    Currently I am printing this using Reportwizard, but I have to do this by using POS Printer.
    I need to print a receipt by programming in C# to a POS Printer
    this data will be populated from database as a data table.  All it needs to do is print a sample receipt that shows the table as shown below.

    This is the format that i am looking for

    ABCDEF Pte. Ltd.
    123 My Street, My City,
    My State, My Country
    012-3456789
    ---------------------------------------------------------
    DATE : 01/01/1970
    CASHIER : ABCDEF

    item(width 5cm)        qty(width 1cm) Unit Price (width 2cm)   Total (width 2cm)
    ================================================================
    Item 1                         10                        9.99                                 99.99
    Item 2                         101                      0.00                                   0.00
    Item 3                          9                         0.10                                   0.90
    Item 4                          1000                   1.00                             1000.00
    ------------------------------------------------------------------------------------------------
                                                                SUB-TOTAL                    1.00
                                                                TAX                                 0.10
                                                                DISCOUNT                       0.10
                                                                ---------------------------------------------------
                                                                TOTAL                            0.80
                                                                ---------------------------------------------------

                               THANK YOU FOR CHOOSING ABC Pte. Ltd. 


    Please post the sample code for printing datatable at a time. I am using EPSON TM-T111V8 Printer.

    Thanks in Advance
    Tuesday, December 1, 2009 12:28 PM

Answers

  • Hi again,

    So a couple of things;

    The Report Wizard, Sql Reporting Services, Crystal Reports, Active Reports and other similar report engines are not (at least generally) compatible with Pos .Net, you need to write the code to do the layout and printing yourself, which is why in the past I have recommended inventing and using a PML to simplify this process;

    http://www.yortondotnet.com/2009/07/better-way-to-print-receipts.html

    Secondly, you have specified widths in centimeters. This is not the way most receipt printers work. Most receipt printers default to a 'text mode' rather than a gaphics mode. In text mode, output is very simple and fairly limited, but very fast printing can be achieved and since receipts don't generally require complex formatting this is ok. In 'text mode' all positioning and measurement is done with 'characters' as the unit, i.e you print 10 characters, starting 5 characters in... you don't print 2 centimeters worth of characters starting 1.5 cm in. All printing is done (usually) with a fixed width font to ensure everything lines up. Most printers have a font of a similar size, and they generally print 40-42 characters per line. Some have a 'condensed' mode where they print around double that, but the font is smaller and some people can't read it so that's often best ignored. You will need to change your system so that it works based on number of characters rather than centimeters.  Again, these are generalisations, some receipt printers do have graphical modes and so on, but generally you're best off working with characters.

    Having said all that, here is some code that will print a pretty close approximation of what you asked for. You may need to tweak it a little. I also wouldn't use this code in a production environment, it is only intended as a sample for you. It is rough, slow and poorly architected, but it will demonstrate the kind of techniques you will need to use. If you want to use this code going forward, then as a minimum I would recommend;

    1. Tidy up the code - use constants for the escape sequences etc.
    2. Sort out the exact alignment and positioning you want.
    3. This is the big one... build a single large string (at least as far as possible), and print that, rather than printing tiny little bits of strings seperately. You'll get a reasonably significant performance improvement out of that, and you won't need the printer claimed for as long etc. as you only need to claim it for the one or two print commands, rather than the whole string building sequence.


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.PointOfService;
    
    namespace WindowsFormsApplication1
    {
    	public partial class Form1 : Form
    	{
    		public Form1()
    		{
    			InitializeComponent();
    		}
    
    		private void Form1_Load(object sender, EventArgs e)
    		{
    			PrintReceipt();
    		}
    
    		private void PrintReceipt()
    		{
    			PosPrinter printer = GetReceiptPrinter();
    
    			try
    			{
    				ConnectToPrinter(printer);
    
    				PrintReceiptHeader(printer, "ABCDEF Pte. Ltd.", "123 My Street, My City,", "My State, My Country", "012-3456789", DateTime.Now, "ABCDEF");
    
    				PrintLineItem(printer, "Item 1", 10, 99.99);
    				PrintLineItem(printer, "Item 2", 101, 0.00);
    				PrintLineItem(printer, "Item 3", 9, 0.1);
    				PrintLineItem(printer, "Item 4", 1000, 1);
    
    				PrintReceiptFooter(printer, 1, 0.1, 0.1, "THANK YOU FOR CHOOSING ABC Ptr. Ltd.");
    			}
    			finally
    			{
    				DisconnectFromPrinter(printer);
    			}
    		}
    
    		private void DisconnectFromPrinter(PosPrinter printer)
    		{
    			printer.Release();
    			printer.Close();
    		}
    
    		private void ConnectToPrinter(PosPrinter printer)
    		{
    			printer.Open();
    			printer.Claim(10000);
    			printer.DeviceEnabled = true;
    		}
    
    		private PosPrinter GetReceiptPrinter()
    		{
    			PosExplorer posExplorer = new PosExplorer(this);
    			DeviceInfo receiptPrinterDevice = posExplorer.GetDevice("PosPrinter", "ReceiptPrinter"); //May need to change this if you don't use a logicial name or use a different one.
    			return (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);
    		}
    
    		private void PrintReceiptFooter(PosPrinter printer, int subTotal, double tax, double discount, string footerText)
    		{
    			string offSetString = new string(' ', printer.RecLineChars / 2);
    
    			PrintTextLine(printer, new string('-', (printer.RecLineChars / 3) * 2));
    			PrintTextLine(printer, offSetString + String.Format("SUB-TOTAL     {0}", subTotal.ToString("#0.00")));
    			PrintTextLine(printer, offSetString + String.Format("TAX           {0}", tax.ToString("#0.00")));
    			PrintTextLine(printer, offSetString + String.Format("DISCOUNT      {0}", discount.ToString("#0.00")));
    			PrintTextLine(printer, offSetString + new string('-', (printer.RecLineChars / 3)));
    			PrintTextLine(printer, offSetString + String.Format("TOTAL         {0}", (subTotal - (tax + discount)).ToString("#0.00")));
    			PrintTextLine(printer, offSetString + new string('-', (printer.RecLineChars / 3)));
    			PrintTextLine(printer, String.Empty);
    
    			//Embed 'center' alignment tag on front of string below to have it printed in the center of the receipt.
    			PrintTextLine(printer, System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, (byte)'|', (byte)'c', (byte)'A' }) + footerText);
    
    			//Added in these blank lines because RecLinesToCut seems to be wrong on my printer and
    			//these extra blank lines ensure the cut is after the footer ends.
    			PrintTextLine(printer, String.Empty);
    			PrintTextLine(printer, String.Empty);
    			PrintTextLine(printer, String.Empty);
    			PrintTextLine(printer, String.Empty);
    			PrintTextLine(printer, String.Empty);
    
    			//Print 'advance and cut' escape command.
    			PrintTextLine(printer, System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, (byte)'|', (byte)'1', (byte)'0', (byte)'0', (byte)'P', (byte)'f', (byte)'P' }));
    		}
    
    		private void PrintLineItem(PosPrinter printer, string itemCode, int quantity, double unitPrice)
    		{
    			PrintText(printer, TruncateAt(itemCode.PadRight(9), 9));
    			PrintText(printer, TruncateAt(quantity.ToString("#0.00").PadLeft(9), 9));
    			PrintText(printer, TruncateAt(unitPrice.ToString("#0.00").PadLeft(10), 10));
    			PrintTextLine(printer, TruncateAt((quantity * unitPrice).ToString("#0.00").PadLeft(10), 10));
    		}
    
    		private void PrintReceiptHeader(PosPrinter printer, string companyName, string addressLine1, string addressLine2, string taxNumber, DateTime dateTime, string cashierName)
    		{
    			PrintTextLine(printer, companyName);
    			PrintTextLine(printer, addressLine1);
    			PrintTextLine(printer, addressLine2);
    			PrintTextLine(printer, taxNumber);
    			PrintTextLine(printer, new string('-', printer.RecLineChars / 2));
    			PrintTextLine(printer, String.Format("DATE : {0}", dateTime.ToShortDateString()));
    			PrintTextLine(printer, String.Format("CASHIER : {0}", cashierName));
    			PrintTextLine(printer, String.Empty);
    			PrintText(printer, "item      ");
    			PrintText(printer, "qty       ");
    			PrintText(printer, "Unit Price ");
    			PrintTextLine(printer, "Total      ");
    			PrintTextLine(printer, new string('=', printer.RecLineChars));
    			PrintTextLine(printer, String.Empty);
    
    		}
    
    		private void PrintText(PosPrinter printer, string text)
    		{
    			if (text.Length <= printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, text); //Print text
    			else if (text.Length > printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, TruncateAt(text, printer.RecLineChars)); //Print exactly as many characters as the printer allows, truncating the rest.
    		}
    
    		private void PrintTextLine(PosPrinter printer, string text)
    		{
    			if (text.Length < printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, text + Environment.NewLine); //Print text, then a new line character.
    			else if (text.Length > printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, TruncateAt(text, printer.RecLineChars)); //Print exactly as many characters as the printer allows, truncating the rest, no new line character (printer will probably auto-feed for us)
    			else if (text.Length == printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, text + Environment.NewLine); //Print text, no new line character, printer will probably auto-feed for us.
    		}
    
    		private string TruncateAt(string text, int maxWidth)
    		{
    			string retVal = text;
    			if (text.Length > maxWidth)
    				retVal = text.Substring(0, maxWidth);
    
    			return retVal;
    		}
    
    	}
    }
    
    Sunday, December 6, 2009 10:16 PM
    Answerer

All replies

  • Hi again,

    So a couple of things;

    The Report Wizard, Sql Reporting Services, Crystal Reports, Active Reports and other similar report engines are not (at least generally) compatible with Pos .Net, you need to write the code to do the layout and printing yourself, which is why in the past I have recommended inventing and using a PML to simplify this process;

    http://www.yortondotnet.com/2009/07/better-way-to-print-receipts.html

    Secondly, you have specified widths in centimeters. This is not the way most receipt printers work. Most receipt printers default to a 'text mode' rather than a gaphics mode. In text mode, output is very simple and fairly limited, but very fast printing can be achieved and since receipts don't generally require complex formatting this is ok. In 'text mode' all positioning and measurement is done with 'characters' as the unit, i.e you print 10 characters, starting 5 characters in... you don't print 2 centimeters worth of characters starting 1.5 cm in. All printing is done (usually) with a fixed width font to ensure everything lines up. Most printers have a font of a similar size, and they generally print 40-42 characters per line. Some have a 'condensed' mode where they print around double that, but the font is smaller and some people can't read it so that's often best ignored. You will need to change your system so that it works based on number of characters rather than centimeters.  Again, these are generalisations, some receipt printers do have graphical modes and so on, but generally you're best off working with characters.

    Having said all that, here is some code that will print a pretty close approximation of what you asked for. You may need to tweak it a little. I also wouldn't use this code in a production environment, it is only intended as a sample for you. It is rough, slow and poorly architected, but it will demonstrate the kind of techniques you will need to use. If you want to use this code going forward, then as a minimum I would recommend;

    1. Tidy up the code - use constants for the escape sequences etc.
    2. Sort out the exact alignment and positioning you want.
    3. This is the big one... build a single large string (at least as far as possible), and print that, rather than printing tiny little bits of strings seperately. You'll get a reasonably significant performance improvement out of that, and you won't need the printer claimed for as long etc. as you only need to claim it for the one or two print commands, rather than the whole string building sequence.


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.PointOfService;
    
    namespace WindowsFormsApplication1
    {
    	public partial class Form1 : Form
    	{
    		public Form1()
    		{
    			InitializeComponent();
    		}
    
    		private void Form1_Load(object sender, EventArgs e)
    		{
    			PrintReceipt();
    		}
    
    		private void PrintReceipt()
    		{
    			PosPrinter printer = GetReceiptPrinter();
    
    			try
    			{
    				ConnectToPrinter(printer);
    
    				PrintReceiptHeader(printer, "ABCDEF Pte. Ltd.", "123 My Street, My City,", "My State, My Country", "012-3456789", DateTime.Now, "ABCDEF");
    
    				PrintLineItem(printer, "Item 1", 10, 99.99);
    				PrintLineItem(printer, "Item 2", 101, 0.00);
    				PrintLineItem(printer, "Item 3", 9, 0.1);
    				PrintLineItem(printer, "Item 4", 1000, 1);
    
    				PrintReceiptFooter(printer, 1, 0.1, 0.1, "THANK YOU FOR CHOOSING ABC Ptr. Ltd.");
    			}
    			finally
    			{
    				DisconnectFromPrinter(printer);
    			}
    		}
    
    		private void DisconnectFromPrinter(PosPrinter printer)
    		{
    			printer.Release();
    			printer.Close();
    		}
    
    		private void ConnectToPrinter(PosPrinter printer)
    		{
    			printer.Open();
    			printer.Claim(10000);
    			printer.DeviceEnabled = true;
    		}
    
    		private PosPrinter GetReceiptPrinter()
    		{
    			PosExplorer posExplorer = new PosExplorer(this);
    			DeviceInfo receiptPrinterDevice = posExplorer.GetDevice("PosPrinter", "ReceiptPrinter"); //May need to change this if you don't use a logicial name or use a different one.
    			return (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);
    		}
    
    		private void PrintReceiptFooter(PosPrinter printer, int subTotal, double tax, double discount, string footerText)
    		{
    			string offSetString = new string(' ', printer.RecLineChars / 2);
    
    			PrintTextLine(printer, new string('-', (printer.RecLineChars / 3) * 2));
    			PrintTextLine(printer, offSetString + String.Format("SUB-TOTAL     {0}", subTotal.ToString("#0.00")));
    			PrintTextLine(printer, offSetString + String.Format("TAX           {0}", tax.ToString("#0.00")));
    			PrintTextLine(printer, offSetString + String.Format("DISCOUNT      {0}", discount.ToString("#0.00")));
    			PrintTextLine(printer, offSetString + new string('-', (printer.RecLineChars / 3)));
    			PrintTextLine(printer, offSetString + String.Format("TOTAL         {0}", (subTotal - (tax + discount)).ToString("#0.00")));
    			PrintTextLine(printer, offSetString + new string('-', (printer.RecLineChars / 3)));
    			PrintTextLine(printer, String.Empty);
    
    			//Embed 'center' alignment tag on front of string below to have it printed in the center of the receipt.
    			PrintTextLine(printer, System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, (byte)'|', (byte)'c', (byte)'A' }) + footerText);
    
    			//Added in these blank lines because RecLinesToCut seems to be wrong on my printer and
    			//these extra blank lines ensure the cut is after the footer ends.
    			PrintTextLine(printer, String.Empty);
    			PrintTextLine(printer, String.Empty);
    			PrintTextLine(printer, String.Empty);
    			PrintTextLine(printer, String.Empty);
    			PrintTextLine(printer, String.Empty);
    
    			//Print 'advance and cut' escape command.
    			PrintTextLine(printer, System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, (byte)'|', (byte)'1', (byte)'0', (byte)'0', (byte)'P', (byte)'f', (byte)'P' }));
    		}
    
    		private void PrintLineItem(PosPrinter printer, string itemCode, int quantity, double unitPrice)
    		{
    			PrintText(printer, TruncateAt(itemCode.PadRight(9), 9));
    			PrintText(printer, TruncateAt(quantity.ToString("#0.00").PadLeft(9), 9));
    			PrintText(printer, TruncateAt(unitPrice.ToString("#0.00").PadLeft(10), 10));
    			PrintTextLine(printer, TruncateAt((quantity * unitPrice).ToString("#0.00").PadLeft(10), 10));
    		}
    
    		private void PrintReceiptHeader(PosPrinter printer, string companyName, string addressLine1, string addressLine2, string taxNumber, DateTime dateTime, string cashierName)
    		{
    			PrintTextLine(printer, companyName);
    			PrintTextLine(printer, addressLine1);
    			PrintTextLine(printer, addressLine2);
    			PrintTextLine(printer, taxNumber);
    			PrintTextLine(printer, new string('-', printer.RecLineChars / 2));
    			PrintTextLine(printer, String.Format("DATE : {0}", dateTime.ToShortDateString()));
    			PrintTextLine(printer, String.Format("CASHIER : {0}", cashierName));
    			PrintTextLine(printer, String.Empty);
    			PrintText(printer, "item      ");
    			PrintText(printer, "qty       ");
    			PrintText(printer, "Unit Price ");
    			PrintTextLine(printer, "Total      ");
    			PrintTextLine(printer, new string('=', printer.RecLineChars));
    			PrintTextLine(printer, String.Empty);
    
    		}
    
    		private void PrintText(PosPrinter printer, string text)
    		{
    			if (text.Length <= printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, text); //Print text
    			else if (text.Length > printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, TruncateAt(text, printer.RecLineChars)); //Print exactly as many characters as the printer allows, truncating the rest.
    		}
    
    		private void PrintTextLine(PosPrinter printer, string text)
    		{
    			if (text.Length < printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, text + Environment.NewLine); //Print text, then a new line character.
    			else if (text.Length > printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, TruncateAt(text, printer.RecLineChars)); //Print exactly as many characters as the printer allows, truncating the rest, no new line character (printer will probably auto-feed for us)
    			else if (text.Length == printer.RecLineChars)
    				printer.PrintNormal(PrinterStation.Receipt, text + Environment.NewLine); //Print text, no new line character, printer will probably auto-feed for us.
    		}
    
    		private string TruncateAt(string text, int maxWidth)
    		{
    			string retVal = text;
    			if (text.Length > maxWidth)
    				retVal = text.Substring(0, maxWidth);
    
    			return retVal;
    		}
    
    	}
    }
    
    Sunday, December 6, 2009 10:16 PM
    Answerer
  • Hi Terry,

    Thanks for your Answer, Really it helped me alot.

    I am able to print the items as required but while cutting the page, i am not able to give the exact size where to cut the bill.

    oPrinter.CutPaper(10);  /* Its taking integer parameters but not sure how much do i need to give the size*/.

    I want to cut the paper after printing the bill, some times itshowing error also.  see the Jing screen shot of the error message.  http://screencast.com/t/NzFiNjYyZTIt .


    Thanks in advance.

    Thursday, December 17, 2009 2:10 PM
  • I used the escape code for 'advance and cut' in PrintFooter method, but the Cut method on the printer object should work too. I'm not sure what you mean by the 'size' of the bill... the parameter you pass to cut is the % of the paper width to cut. For example, a value of 50 would cut half the receipt paper (across). Normally you would use either 90 or 100%, as you either want the paper cut entirely, or you want it mostly cut but not completely so it doesn't fall out of the printer.

    Unfortunately I haven't ever seen the error in your screenshot before. When do you get it ? Is it related to the cut, or some other part of the printing ?
    It seems like a timeout issue, which might indicate a problem with your printer, it's connection (serial port settings??) or perhaps the specific service object being used.

    If you change my code to use transactional printing (see the Pos .Net SDK documentation for how to do so), then that may or may not alleviate the problem as the printer/service object might be able to buffer the comamnds better in that mode (printing should be faster too).
    Thursday, December 17, 2009 8:34 PM
    Answerer
  • Hi Yort,

    Thanks for your answer, now i am able to cut the paper size as i reqired. As i am testing my application, while keep on printing the Reciepts, runtime issues occured in the application. not able to know the reason why they come and one more, some times the printer is hangup for some time.
    Could you please let me know what might be the reason. here the sample code and error message in detail.

    try

    {

     

    //Prepare PrinterHeader
    string sHeader = Environment.NewLine +" XYZ " + Environment.NewLine +" www.xyz.com " + Environment.NewLine +" Sales : 400 " + Environment.NewLine +" Welcome : 123 " + Environment.NewLine + "--------------------------------------" + Environment.NewLine;
    oPrinter.PrintNormal(
    PrinterStation.Receipt, sHeader);

    //Print Bill Info
    foreach (DataRow dr in ds.Tables[0].Rows)
    {
    iCount++;
    str +=
    "Customer Id" + dr["CustomerId"].ToString() + "--" + dr["TotalAmount"].ToString() + Environment.NewLine;
    }
    oPrinter.PrintNormal(
    PrinterStation.Receipt, str);
    //Printer Footer
    string sFooter = Environment.NewLine +"----------------------------------------" + Environment.NewLine + " Note : (*) Are Loyalty Incentives " + Environment.NewLine +" Thank You For Visiting " + Environment.NewLine + "----------------------------------------" + Environment.NewLine;
    oPrinter.PrintNormal(
    PrinterStation.Receipt, sFooter);
    //Print EmptyLines
    string sEmptyLines = string.Empty;
    sEmptyLines =
    Environment.NewLine +Environment.NewLine +Environment.NewLine +Environment.NewLine +Environment.NewLine +Environment.NewLine;
    oPrinter.PrintNormal(
    PrinterStation.Receipt, sEmptyLines);
    //Cut the Paper
    oPrinter.CutPaper(1);
    }
    catch (Exception ex)
    {
       MessageBox.Show(ex.ToString());
    }


     

    Error Message :

    Microsoft.PointOfService.PosControlException: It could not complete output within the specified period.   at jp.co.epson.upos.trace.pntr.CommonPosPrinterTraceService.PrintNormal(PrinterStation station, String data)   at MSR1.frmPoleDisplay.button1_Click(Object sender, EventArgs e) in D:\C Drive Backup\POS Driver Implementation\CS_Examples\CS_Examples\MSR1\MSR1\frmPoleDisplay.cs:line 201ErrorCode: FailureErrorCodeExtended: 1007

     

    Friday, December 18, 2009 7:48 AM
  • how can i get using Microsoft.PointOfService
    i am not getting it...

    Friday, January 29, 2010 6:21 AM

  • You question should be in a new thread. There is a good introduction video here: http://channel9.msdn.com/posts/scobleizer/Craig-Jensen-Windows-Embedded-for-Point-of-Sale/


    I have some sample applications and other information here: http://www.seanliming.com/WEPOS.html


    -Sean

    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
    Friday, January 29, 2010 3:14 PM
    Answerer
  • private
     PosPrinter GetReceiptPrinter()
    {
    DeviceInfo receiptPrinterDevice = posExplorer.GetDevice("PosPrinter" , "ReceiptPrinter" ); //May need to change this if you don't use a logicial name or use a different one.

    }
    I want to use POS-Printer,what will i have to do ,cz in the above method,i m getting NULL value

    Plz mail me aftab5124@yahoo.com
    Monday, February 1, 2010 12:15 PM
  • Hi,

    The above code requests a PosPrinter object with a logical name of PosPrinter. If it is returning null then mostly likely;

    1. You have not set up a logical name for your printer (in the above code the logical name is ReceiptPrinter. You can setup a logical name with Sean Liming's somgr.exe (www.seanliming.com).

    2. You do not have a service object for your printer installed (and also no logical name), and so the printer is not correctly installed on your system. You will need to download and install the service objects for you make and model of printer, then setup the logical name.

    Alternatively, you could change the code so it doesn't use a logical name but instead just gets a list of PosPrinter devices and uses the first or last one it uses... but you will still need the appropriate service objects installed.
    Monday, February 1, 2010 7:02 PM
    Answerer
  • Where can i get the assembly (namespace) to be able to use the PointOfService

     

    using Microsoft.PointOfService;

     

    Thanks in advance.

     

     

    Wednesday, May 19, 2010 2:01 AM
  • Are you asking about how to use POS for .NET or how to access a Service Object?

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
    Wednesday, May 19, 2010 4:49 AM
    Answerer
  • How to access a Service Object?

     

    In yort's code, he used a namespace from microsoft called PointOfService and then he used methods from this namespace.

    how can i do this?

    My visual studio doesn't have this namespace, where can i find it?

     

    Thanks in advance.

    Wednesday, May 19, 2010 11:52 AM
  • I downloaded POS for .Net v1.12 and installed it. I would Like to know how to refer it to my application
    Wednesday, May 19, 2010 12:23 PM
  • I get it.
    Wednesday, May 19, 2010 1:10 PM
  • What Yort added was a logical name. You can add a Logical Name using POSDM or my SOManager- http://www.seanliming.com/WEPOS.html. Logical names are good when there are multiple devices of the same type connected.

    If you only had a single device, the following could work:

    DeviceInfo receiptPrinterDevice = posExplorer.GetDevice("PosPrinter");

    -Sean

     

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
    Wednesday, May 19, 2010 3:13 PM
    Answerer
  • Hi,

    It depends on where you installed Pos .Net to, but the usual path for the dll you need to reference is;

    C:\Program Files\Microsoft Point Of Service\SDK\Microsoft.PointOfService.dll

     

     

    Wednesday, May 19, 2010 9:14 PM
    Answerer
  • Is the POS class handle any receipt printer? if no then, which receipt printer can he handle? thanks in advance.
    Saturday, May 22, 2010 10:48 AM
  • Hi,

    You really should make new threads for these questions instead of posting to the bottom of closed threads.

    Yes, Pos .Net (like OPOS) is designed to insulate you from specific models and brands of hardware. That is, you should be able to write your code to work with Pos .Net and then use it with many different printers... and this works ok most of the time, sort of.

    No, it does not work with ALL printers. It should work with any printer that has either an OPOS or Pos .Net service object available for it.

    For a list of known service objects, and issues that can still crop up when trying to use Pos .Net for device independence see;

    http://www.yortondotnet.com/2009/09/pos-net-and-opos-service-object-links.html

    http://www.yortondotnet.com/2009/08/pos-net-series-post-4-device.html

    http://www.yortondotnet.com/2009/08/pos-net-series-post-5-tpg-and-epson.html

     

    Saturday, May 22, 2010 9:58 PM
    Answerer
  • I have the same problem

     

    DeviceInfo receiptPrinterDevice = posExplorer.GetDevice("PosPrinter", "ReceiptPrinter");  retunr null, don´t detect the pos printer

    I use VS2010 / Win 7 and the printer is  TM-T81 using USB port

    Please mail me to oscarlcs@hotmail.com or gerencia@ciudadtecnopolis.com

    Saturday, June 12, 2010 10:25 PM
  • The solution : Use DLL Locate in programn files, i try use from diferent location from installed folder fails..
    Saturday, June 12, 2010 11:20 PM
  • hii 

    I m really new to programming ,,,, i want some perfect sample code for Recipt printing if u can help me then i will b really thankful to u 

    i have tried the same above code but getting namespace error 

    Error 1 The type or namespace name 'PosPrinter' could not be found (are you missing a using directive or an assembly reference?)

    Error 2 ..... error 18 

    Saturday, June 28, 2014 4:08 PM
  • Hi Terry

    Thanks for your valuable information

    my question is it required a PosPrinter connected to my PC in order that your sample code yield output?

    Friday, February 27, 2015 9:25 AM
  • If you are trying to print to the device, then yes, the device needs to be connected.

    www.annabooks.com / www.seanliming.com / Book Author - Pro Guide to WE8S, Pro Guide to WES 7, Pro Guide to POS for .NET

    Friday, February 27, 2015 5:19 PM
    Answerer
  • Hai

    I use this code in my project, but there show some error like PosPrinter,PosExplorer,DeviceInfo,PrinterStation.

    Please give me solution what can I do ?

    thanks


    • Edited by Asad7142 Wednesday, September 30, 2015 8:20 AM
    Wednesday, September 30, 2015 8:19 AM