Печать с помощью проблемы печати документа в C#
Проблема № 1=>
Я печатаю квитанцию клиента, но когда я добавляю более 20 продуктов, то он генерирует новую страницу, и Заголовок 1-й страницы также отображается на новой странице, но я хочу, чтобы он показывал только детали продукта в новом заголовке страницы, Пожалуйста, скажите мне, как я могу это сделать.
проблема № 2=>
когда добавляется более 1 страницы, то я беру печать с помощью термопринтера проблема в том, что он печатает только первую страницу и пропускает другие страницы .но я хочу, чтобы он печатал все страницы, которые больше 1 страницы, только на одной странице, которая печатается термопринтером.
Проблема № =>
когда я добавил еще 20 продуктов то он непрерывно генерирует новую страницу и не прекращает генерировать новую страницу
Что я уже пробовал:
Это мой код, который используется для печати квитанции клиента
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //this method get data from database and fill in list 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("Qty", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(340, 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 ypos = 250; 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); // e.Graphics.DrawString(Convert.ToString( _List[i].Qty), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startX + 330, 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("----------------------------------------------------------------------------------", //new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(startX, startY)); e.Graphics.DrawString("Total Amount :" + TotalAmounttextBox.Text.Trim(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(startX + 10 , startY + 30)); //rest thhe veriable NumberofExpensperPage = 0; NumberOfItemPrintedSofar = 0; _List.Clear(); }