Hello friends please help me , i have been suffering with this since 2 weeks .
I have made a POS application for a restaurant . with Win-form ,c# ,.Net .
The printer Epson TM-U220 is printing the junk characters with my app.
However when i tried to print a normal text through notepad on Epson TM-U220 , it was junk too.
Now the magic is The restaurant owner has an old POS application for bill printing with that only this Epson TM-U220 prints correctly .
One more thing my app prints fine with other Inkjet & Laser printers
I am really frustrated & confused i have reinstalled the drivers for printer but still the same situation ..Can anyone please help me .
Hear is my code for printing
Rajkumar
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using System.Windows;
using System.Runtime.InteropServices;
using Telerik.WinControls.UI;
using System.Data.OleDb;
using CrystalDecisions.CrystalReports.Engine;
using System.IO;
using System.Collections;
using System.Configuration;
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
int width = 0;
int height = 0;
int x = 0;
int y = 0;
int rowheight = 0;
int columnwidth = 0;
StringFormat str = new StringFormat();
str.Alignment = StringAlignment.Near;
str.LineAlignment = StringAlignment.Center;
str.Trimming = StringTrimming.EllipsisCharacter;
Pen p = new Pen(Color.Black, 2.5f);
Font drawFont = new Font("Arial",10);
Font drawFont2 = new Font("Arial Black", 10);
Font drawFont3 = new Font("Lucida Console", 8);
#region Draw Column 1
int xb ;
if(radGridView3.Rows.Count ==1 )
{xb = 200;}
else
{xb= radGridView3.Rows.Count* 100 ;}
float[] dashValues = { 2, 2, 2, 2 };
Pen blackPen = new Pen(Color.Black, 1);
e.Graphics.DrawString(" Hotel Name ", drawFont2, Brushes.Black, new RectangleF(76, 76, 300, 26), str);
e.Graphics.DrawString(" -----------------------CASH MEMO-----------------------", radGridView3.Font, Brushes.Black, new RectangleF(10,100, 500, 26), str);
blackPen.DashPattern = dashValues;
e.Graphics.DrawLine(blackPen, new Point(20, 135), new Point(300, 135));
e.Graphics.DrawString(" Bill No: ", radGridView3.Font, Brushes.Black, new RectangleF(17, 110, 400, 26), str);
e.Graphics.DrawString(txtbid.Text.ToString(), radGridView3.Font, Brushes.Black, new RectangleF(55,110, 250, 26), str);
e.Graphics.DrawString(" W No: ", radGridView3.Font, Brushes.Black, new RectangleF(245, 110, 400, 26), str);
e.Graphics.DrawString(txtlogid.Text.ToString(), radGridView3.Font, Brushes.Black, new RectangleF(285,110, 250, 26), str);
e.Graphics.DrawString("Particulars Quantity Rate ", radGridView3.Font, Brushes.Black, new RectangleF(20,130, 400, 26), str);
blackPen.DashPattern = dashValues;
e.Graphics.DrawLine(blackPen, new Point(20, 150), new Point(300, 150));
#endregion
#region Draw column 2
e.Graphics.DrawString(radGridView3.Columns[1].HeaderText, radGridView3.Font, Brushes.Black, new RectangleF(100 + 180, 100, 180, radGridView3.Rows[0].Height), str);
width = 100 + 180;
height = 130;
while (i < radGridView3.Rows.Count)
{
if (height > e.MarginBounds.Height)
{
height = 100;
width = 100;
e.HasMorePages = true;
return;
}
height += 26;
e.Graphics.DrawString(radGridView3.Rows[i].Cells[0].Value.ToString(), radGridView3.Font, Brushes.Black, new RectangleF(20, height, 180, 26), str);
e.Graphics.DrawString(radGridView3.Rows[i].Cells[1].Value.ToString(), radGridView3.Font, Brushes.Black, new RectangleF(20 + 130, height, 180, 26), str);
e.Graphics.DrawString(radGridView3.Rows[i].Cells[3].Value.ToString(), radGridView3.Font, Brushes.Black, new RectangleF(20 + 130 + 20, height, 180, 26), str);
e.Graphics.DrawString(radGridView3.Rows[i].Cells[2].Value.ToString(), radGridView3.Font, Brushes.Black, new RectangleF(20 + 170 + 60 , height, 180, 26), str);
width += 180;
i++;
}
e.Graphics.DrawString(System.DateTime.Now.ToString(), radGridView3.Font, Brushes.Black, new RectangleF(30, height+26, 250, 26), str);
if (txtdescount.Text == "")
{ e.Graphics.DrawString(radTextBox1.Text.ToString(), drawFont3, Brushes.Black, new RectangleF(250, height + 28, 250, 26), str);
e.Graphics.DrawString("Grand Total :Rs.", radGridView3.Font, Brushes.Black, new RectangleF(165, height + 26, 250, 26), str);
}
else
{
e.Graphics.DrawString(txtdescount.Text.ToString(), drawFont3, Brushes.Black, new RectangleF(250, height + 26+10+2+3, 250, 26), str);
e.Graphics.DrawString(radTextBox1.Text.ToString(), drawFont3, Brushes.Black, new RectangleF(250, height + 28, 250, 26), str);
e.Graphics.DrawString(txtgrtotal.Text.ToString(), drawFont3, Brushes.Black, new RectangleF(250, height + 28+11+11+2, 250, 26), str);
e.Graphics.DrawString(" Total :Rs.", radGridView3.Font, Brushes.Black, new RectangleF(165, height + 26, 250, 26), str);
e.Graphics.DrawString(" Discount:Rs.", radGridView3.Font, Brushes.Black, new RectangleF(165, height + 26+11+2, 250, 26), str);
e.Graphics.DrawString("Grand Total :Rs.", radGridView3.Font, Brushes.Black, new RectangleF(165, height + 26 + 11+11+2, 250, 26), str);
}
e.Graphics.DrawString("------Thank You------- ", radGridView3.Font, Brushes.Black, new RectangleF(85, height + 50+11, 250, 26), str);
blackPen.DashPattern = dashValues;
e.Graphics.DrawLine(blackPen, new Point(20, height + 20), new Point(300, height + 20));
i = 0;
#endregion
#region Draw Column 3
#endregion
}
catch { }
}
private void button1_Click(object sender, EventArgs e)
{
printDocument1.Print();
}