Search code examples
c#thermal-printer

RawPrinter Helper: Printer not printing Tamil characters


Trying to print tamil characters in thermal printer. and getting '????' or any other garbage character. code I am using is as follows.

         Print(eInit + 'நன்றி');

         public void Print(string Line)
         {
             prn.SendStringToPrinter(PrinterName, Line);
         }

         public bool SendStringToPrinter(string szPrinterName, string szString)
         {
             bool functionReturnValue = false;
             if (PrinterOpen)
             {
                 IntPtr pBytes = default(IntPtr);
                 Int32 dwCount = default(Int32);
                 Int32 dwWritten = 0;
                 dwCount = szString.Length;
                 pBytes = Marshal.StringToCoTaskMemAnsi(szString);
                 functionReturnValue = WritePrinter(hPrinter, pBytes, dwCount, ref dwWritten);
                 Marshal.FreeCoTaskMem(pBytes);
             }
             else
             {
                 functionReturnValue = false;
             }
             return functionReturnValue;
         }

Solution

  • Raw printer helper class wont print tamil characters through sensstringtoprinter() class. Design a crystal report select your field and set font as any tamil font(eg. bamini font) and call this report to print from your application on button click event.