Problem No 1=>
I'm printing customer receipt but when i add more then 20 product then it generate new page and the header of 1st page also show in new page but i want it show only product details in new page header is show only first page please tell me how can i do this.
problem No 2=>
when more then 1 page are added then i take print using Thermal printer the problem is that it print only first page and skip the other pages .but i want it print all the pages that is more then 1 page in only one page that is printed by thermal printer.
Problem No =>
when i added more the 20 product then it continuously generate new page and not stop to generating new page
What I have tried:
Its my code that is use to print customer Receipt
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
FillListforprintingItems();
e.Graphics.DrawString("Date :" + DateTime.Now, new Font("Arial", 12, FontStyle.Bold),
Brushes.Black, 200,50);
e.Graphics.DrawString("------------------------------------------------------------------------------------",
new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(9, 85));
e.Graphics.DrawString("Product", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(10,100));
e.Graphics.DrawString("Amount", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(180, 100));
e.Graphics.DrawString
("------------------------------------------------------------------------------------"
,new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(9, 115));
int startX = 10;
int startY = 140;
int offset = 40;
for (int i = NumberOfItemPrintedSofar; i < _List.Count; i++)
{
NumberofExpensperPage++;
if (NumberofExpensperPage <= 20)
{
NumberOfItemPrintedSofar++;
if (NumberOfItemPrintedSofar <= _List.Count)
{
e.Graphics.DrawString(_List[i].Qty+" X " +_List[i].Name, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startX, startY);
e.Graphics.DrawString(Convert.ToString("Vat % :"+_List[i].vateparecent), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startX, startY + 20);
string colorsize = _List[i].sizcolor;
if (colorsize != "")
{
e.Graphics.DrawString(Convert.ToString(colorsize), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startX, startY + 40);
}
e.Graphics.DrawString(_List[i].amountwithvat.ToString(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startX + 170, startY);
if (colorsize != "")
{
e.Graphics.DrawString
("----------------------------------------------------------------------------------",
new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(startX, startY = startY + 55));
}
if (colorsize == "")
{
e.Graphics.DrawString
("----------------------------------------------------------------------------------",
new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(startX, startY = startY + 35));
}
startY += 15;
}
else
{
e.HasMorePages = false;
}
}
else
{
NumberofExpensperPage = 0;
e.HasMorePages = true;
return;
}
}
e.Graphics.DrawString("Total Amount :" + TotalAmounttextBox.Text.Trim(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(startX + 10 , startY + 30));
NumberofExpensperPage = 0;
NumberOfItemPrintedSofar = 0;
_List.Clear();
}