How To Print Arabic Text on windows Application

Jun 6 2016 10:22 AM
Any one can help me for Print Arabic Text on My invoice Print (using e.Graphics.DrawString)
 
 am showing my sample code 
 
 
#region Print
 
 
Font font10 = new Font("Courier New", 10, FontStyle.Bold);
Font font12 = new Font("Courier New", 12);
Font font14 = new Font("Courier New", 14, FontStyle.Bold);
Font font8 = new Font("Times New Roman", 7, FontStyle.Regular);
float leading = 4;
float lineheight10 = font10.GetHeight() + leading;
float lineheight12 = font12.GetHeight() + leading;
float lineheight14 = font14.GetHeight() + leading;
float lineheight8 = font8.GetHeight() + leading;
float startX = 0;
float startY = leading;
float Offset = 0;
float OffsetX = 0;
StringFormat formatLeft = new StringFormat(StringFormatFlags.NoClip);
StringFormat formatCenter = new StringFormat(formatLeft);
StringFormat formatRight = new StringFormat(formatLeft);
formatCenter.Alignment = StringAlignment.Center;
formatRight.Alignment = StringAlignment.Far;
formatLeft.Alignment = StringAlignment.Near;
SizeF layoutSize = new SizeF(297 - Offset * 2, lineheight14);
RectangleF layout = new RectangleF(new PointF(startX, startY + Offset), layoutSize);
Brush brush = Brushes.Black;
print_companydetails();
e.Graphics.DrawString("??? ???????? :" + txtinvoicenumber.Text.Trim() + " " + "??????? : " + DateTime.Now.ToString("dd/MM/yyyy") + "", font10, brush, layout, formatLeft);
Offset = Offset + lineheight10;
layout = new RectangleF(new PointF(startX, startY + Offset), layoutSize);
e.Graphics.DrawString("?????? ????????", font12, brush, layout, formatLeft);
Offset = Offset + lineheight12;
layout = new RectangleF(new PointF(startX, startY + Offset), layoutSize);
e.Graphics.DrawString("----------------------------------", font10, brush, layout, formatLeft);
Offset = Offset + lineheight10;
layout = new RectangleF(new PointF(startX, startY + Offset), layoutSize);
e.Graphics.DrawString("??? ???? ??? ???????? ????", font10, brush, layout, formatLeft);
Offset = Offset + lineheight10;
layout = new RectangleF(new PointF(startX, startY + Offset), layoutSize);
e.Graphics.DrawString("----------------------------------", font10, brush, layout, formatLeft);
Offset = Offset + lineheight10;
layout = new RectangleF(new PointF(startX, startY + Offset), layoutSize);
#region with shrink
getDayNo();
objkeep.DayOpenedID = dayno;
objkeep.InvDate = DateTime.ParseExact(dtpdate.Text.Trim(), "dd/MM/yyyy", null);
objkeep.InvNo = Convert.ToDecimal(txtinvoicenumber.Text.Trim());
DataSet ds = objkeep.Shrink_Reprint();
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
SizeF R = new SizeF(0, 0);
e.Graphics.DrawString(ds.Tables[0].Rows[i][1].ToString(), font8, brush, layout, formatLeft);
layout = new RectangleF(new PointF(startX + 160, startY + Offset), R);
e.Graphics.DrawString(ds.Tables[0].Rows[i][2].ToString(), font8, brush, layout, formatRight);
layout = new RectangleF(new PointF(startX + 215, startY + Offset), R);
e.Graphics.DrawString(ds.Tables[0].Rows[i][3].ToString(), font8, brush, layout, formatRight);
layout = new RectangleF(new PointF(startX + 290, startY + Offset), R);
e.Graphics.DrawString(ds.Tables[0].Rows[i][4].ToString(), font8, brush, layout, formatRight);
Offset = Offset + lineheight8;
layout = new RectangleF(new PointF(startX, startY + Offset), layoutSize);
}
}
#endregion
in the above code my text alignment are not proper please help me
 thanks in advance 
 
 

Answers (3)