Hello Guys,Please help me i want to know i have made a restaurant software when i print receipt it's printing receipt but alignment is so out items shows in line but i want align price text on receipt.
What I have tried:
private void printreceipt()
{
PrintDialog printdialog = new PrintDialog();
PrintDocument printdocument = new PrintDocument();
PaperSize bp = new PaperSize("Custom", 100, 200);
printdialog.Document = printdocument;
printdocument.PrintPage += new PrintPageEventHandler(printdocument_PrintPage);
printdocument.DefaultPageSettings.PaperSize = bp;
printdocument.DefaultPageSettings.PaperSize.Height =;
printdocument.DefaultPageSettings.PaperSize.Width = 320;
printdocument.PrinterSettings.PrinterName = setaluefortextprinter;
printdocument.Print();
}
void printdocument_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphics = e.Graphics;
Font f = new Font("Arial", 8);
float fontHeight = f.GetHeight();
int starto = 30;
int startp = 6;
int startX = 10;
int startY = 10;
int offset = 40;
int offset1 = 260;
int offset2 = 280;
int line = 1;
int line1 = 5;
int line2 = 6;
int line3 = 24;
int line4 = 124;
int line5 = 32;
int line6 = 20;
int line7 = 3;
int line8 = 6;
int line9 = 32;
int offset3 = 160;
int offset4 = 170;
int offset5 = 180;
graphics.DrawString(setaluefortext00001name, new Font("Courier New", 15), new SolidBrush(Color.Black), starto, startp);
graphics.DrawString("*************************************************************************************", new Font("Courier New", 6), new SolidBrush(Color.Black), line2, line3);
graphics.DrawString(label4.Text, new Font("Courier New", 6), new SolidBrush(Color.Black), line8, line9);
foreach (tblProduct product in products)
{
string productDescription = product.productName;
string productTotal = " Rs " + string.Format("{0:}", product.productPrice);
string prodcutLine = productDescription + productTotal;
graphics.DrawString(prodcutLine, f, new SolidBrush(Color.Black), startX, startY + offset);
offset = offset + (int)fontHeight + 5;
}
offset = offset + 20;
tblTransaction transaction = new tblTransaction();
transaction.transactionDate = DateTime.Now;
graphics.DrawString("Total To Pay".PadRight(15) + "Rs " + string.Format("{0:}", total), f, new SolidBrush(Color.Black), startX, startY + offset);
graphics.DrawString("Thank You For Coming,".PadRight(15) + string.Format(""), f, new SolidBrush(Color.Black), startX, startY + offset3);
graphics.DrawString("Please Come Back Soon".PadRight(15) + "" + string.Format(""), f, new SolidBrush(Color.Black), startX, startY + offset4);