Click here to Skip to main content
15,887,477 members
Articles / Desktop Programming / MFC
Article

Arabic Fast Print on Receipt Printers

Rate me:
Please Sign up or sign in to vote.
4.11/5 (9 votes)
28 May 20022 min read 121.5K   2.9K   23   23
Allows Arabic POS system developers to work the easiest way on thier receipt printers.

Image 1

The main screen of the demo program.

Introduction

This control is designed for those Arabic developers who are developing systems with receipt printers and want to print Arabic/English characters. This component does not use the graphic mode drivers supplied by the printer manufacturers.

It's fully tested over Citizen CBM series, and under testing on Epson TM series.

The control uses ESC commands which is the most common among several manufacturers of receipt printers.

History

We developed a POS software, and one of the problems we faced was how to print Arabic characters on the receipt printer without using the Windows drivers, and to print Arabic/English at the same line, and considering the language orientation. All this should be faster than that by the Windows graphic drivers.

So, we solved this problem. We developed a VC++ code and solved the problem in a genius way. And for other developers, we made an ActiveX control to deal with the receipt printers.

Usage

The main features:

The developer can use the character set(s) downloaded into the printer, but how to avoid that headache?

  1. It's ActiveX control, can be embedded into any other development language.
  2. It uses the common ESC commands for the printers, so it can work with many printer brands.
  3. It works, even if the desired language character set is not downloaded into the printer ROM. We printed Arabic on a Citizen receipt printer in CBM printers center in Japan where: No Arabic character set on the printer, no windows OS supporting Arabic!!
  4. It's not just Arabic, it can print any other language characters. First, we download the characters into the ActiveX. Besides English.
  5. It's not required that the Windows operating system support that language at all. We print Arabic characters using Citizen receipt printers & Epson on Citizen Japan Ltd. on Windows computer with JP Languages!
  6. It's so easy to use, all the user has to do:
    1. Insert the ActiveX in to his program.
    2. Control.Open (The COM port used here / LPT port).
    3. Choose the Character Mode (32 International characters, or extended 79 characters for Arabic figures).
    4. Load characters (once the control is open).
    5. Choose the language to print and print whatever you want.
    6. User can: print empty line, change orientation, skip line(s), print with/out line feeds, ...

    And at the end of program, just do close the control.

Sample code:

// The activeX control name is: PrnX for example
void InitPrn (CString pComPort)
{
    PrnX.OpenPort (pComPort);
    PrnX.Reset(); //Rest the printer

    //1 = 79 Figures(extended mode for Citizin CBM printers and similars)
    //2 = 32 Figures(restricted mode for Epson & 32
    //       International characters only)
    PrnX.SetChMode (1);

    PrnX.Init();
    //Initialize the printer status & buffer

    PrnX.LoadCharsDefs();
    //Load the international characters into the printer

}

void PrintText (CString pText, short pAllignment)
{
     // Left, Center, Right PrnX.SetAllignment (pAllignment);

     //vLines = Number of empty lines after the print operation. Can be Zero
     short vLines = 2;  

     // Print now as you want.
     // pText may be " any local/english text here
     // -arabic version here- " PrnX.CBMPrint (pText, vLines);

     //And can use PrnX.FeedLine(vLines) also

     //And can do PrnX.CutSheet() to cut the paper if the printer support it
}

void ClosePrnPort ()
{
  PrnX.ClosePort();
}

It's so simple, and very small in size.

If any one wants a demo, we are happy to send the demo version immediately. (Arabic characters exist now, other languages upon request.)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Palestinian Territory (Occupied) Palestinian Territory (Occupied)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionArabic Fast Printing in Receipt Printers Pin
Member 1290163512-Dec-16 22:34
Member 1290163512-Dec-16 22:34 
GeneralWarning: Commercial demo - Not quite the CodeProject way! Pin
TheOtherCritic22-Mar-16 6:28
TheOtherCritic22-Mar-16 6:28 
Since I had to investigate Arabic printing, I stumbled upon this 'sample'. It's way dated (with apparent lack of USB support), the developer's site is dead, and since there seems to be a new law in the middle east that enforces sales tickets in Arabic, I decided to check how this demo worked and see if I can reproduce it. Well, I did. It works. In VB6.

The way the demo works is by sending to the spooler (hence it just needs the port and no settings, and LPT/USB users are outta luck) a long stream of bytes to program the User-Defined-Charset so it prints Arabic. It does so by defining one char at a time (time- and byte-consuming, especially in serial devices). Since Esc/POS is EPSON's trade secret, I will cover my hide by not specifying exactly how. It even incurs in some kind of error, since the last part of the 'definition' stream is some kind of self-advertising, but the printer does not print it when it should, or just deforms it. Maybe a buffer overrun, did not care to investigate.

Then, all that is left is the printing itself. The demo is also wasteful here: For every character to actually print it sends the Esc/POS sequence to select the correct charset (resident or user-defined), and then it sends the character itself. The way I would do it is to send the 'Select User Charset' sequence, then Arabic text, then the 'Select Resident Charset' then the latin text data, or vice-versa. But that actually depends on the final application, right? Beware that redefining characters won't make the printer print Right-To-Left! It's still a Left-To-Right device: You must spell Arabic backwards!

What I did find also is that the demo seems to send also a NUL char right after every Esc/POS sequence. Don't know why. More waste.

Moreover, the definitions made by the demo do not survive an Esc/POS INIT command. Be aware of this.

You can find out all the sequences used by the demo by:
o- Installing an EPSON (or 100% Esc/POS compatible with HEX DUMP capability) serial printer in COM1/COM2 (the only ports supported in the demo).
o- Making sure the printer works as expected; test it.
o- Opening the demo and prepare the options (COMx, Justif., Chars). I used the 79 chars option on EPSON with no issues. Do NOT send definitions or any text yet.
o- Opening the port in the demo.
o- Setting the printer in HEX DUMP mode.
o- Sending the definitions from the demo: The printer gives you the raw hex dump, byte per byte.
o- Feeding some paper to separate definitions from printout.
o- Sending mixed ENG/ARB text from the demo: The printer gives you the raw hex dump, byte per byte.
o- Close the port in the demo.
o- Done.

Now you know how it works. Translate the dumps with EPSON's Esc/POS guide in the EPSON-Biz site.

I used other tricks to get a machine-ready instead of a plain paper hex dump (involved stopping/starting the spooler service and whatnot to fetch its raw data files). I'm lazy to type over 4KB of hex data. Or, you can use your imagination and define a text-only printer and use com-0-com. Maybe it works, dunno.

I'm now NOT using this method (way too slow to send definitions over & over again), and will instead use a TM-T88V, that does support not one but two Arabic codepages.

To know how to use the spooler to send stuff almost-directly to the printer, see Print Direct To Windows Printer (EPOS Receipt)[^] (.Net).

Hope this helps,
TheOtherCritic.
GeneralRe: Warning: Commercial demo - Not quite the CodeProject way! Pin
Member 1147905031-Mar-16 5:26
Member 1147905031-Mar-16 5:26 
GeneralRe: Warning: Commercial demo - Not quite the CodeProject way! Pin
TheOtherCritic14-Apr-16 1:40
TheOtherCritic14-Apr-16 1:40 
Questionhow to print to usb printer Pin
tsalim31-Aug-14 20:05
tsalim31-Aug-14 20:05 
QuestionArabic Fast Print on Receipt Printers Pin
Member 104927082-Jan-14 2:47
Member 104927082-Jan-14 2:47 
GeneralBaud Rate Pin
mikeeball15-Feb-11 2:19
mikeeball15-Feb-11 2:19 
QuestionArticle Source Code Pin
CDRom19-Oct-07 8:47
CDRom19-Oct-07 8:47 
QuestionEpson TM-T88 Compatible Pin
lukejarvis4-Sep-07 20:19
lukejarvis4-Sep-07 20:19 
QuestionCan you help me to assign a character table on my EPSON TM-U210A? Pin
Member 88760614-Oct-04 2:16
Member 88760614-Oct-04 2:16 
QuestionHow can I add a ESC command? Pin
Jason Yen 6228-Mar-04 18:51
professionalJason Yen 6228-Mar-04 18:51 
QuestionThe control is not working even with written code??? Pin
9-Dec-03 23:49
suss9-Dec-03 23:49 
Generalarabic support Pin
Anonymous15-Oct-03 20:18
Anonymous15-Oct-03 20:18 
Generalcorrupt file Pin
Salem18-Nov-02 2:16
Salem18-Nov-02 2:16 
GeneralRe: corrupt file Pin
Tarek Eslim19-Nov-02 2:53
Tarek Eslim19-Nov-02 2:53 
General7elwaaa... Pin
Anonymous22-Sep-02 9:45
Anonymous22-Sep-02 9:45 
GeneralRe: 7elwaaa... Pin
Anonymous5-Mar-03 5:05
Anonymous5-Mar-03 5:05 
Generalquestionable approach Pin
Claudius Mokler28-May-02 21:26
Claudius Mokler28-May-02 21:26 
GeneralRe: questionable approach Pin
29-May-02 7:35
suss29-May-02 7:35 
GeneralRe: questionable approach Pin
8-Jun-02 12:45
suss8-Jun-02 12:45 
GeneralBad link... Pin
jack Mesic28-May-02 14:53
jack Mesic28-May-02 14:53 
GeneralRe: Bad link... Pin
Tarek Eslim29-May-02 3:09
Tarek Eslim29-May-02 3:09 
GeneralRe: Bad link... Pin
BABABIKHIAL14-Nov-08 20:16
BABABIKHIAL14-Nov-08 20:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.