Как напечатать длинное конкретное имя в конкретном столбце с выравниванием текста
i want to print invoice in which Particular,HSNCode and Unit, Batch, Exp and so on.. these items are in my invoice but when particular text size is like "Metaformin Hydrochloride Sustained" or more than this it overlap with HSNCode and Unit, how to adjust text size in a "Particular Column"
Что я уже пробовал:
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Image image = Resources.ppreview; e.Graphics.DrawImage(image, 0, 0, image.Width, image.Height); Image img = Resources.printlogo2; e.Graphics.DrawImage(img, 510, 01, image.Width, image.Height); e.Graphics.DrawString("Name: " + textBox2.Text.Trim(), new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(35, 220)); e.Graphics.DrawString("Mobile No : " + textBox3.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(35, 250)); //Bill e.Graphics.DrawString("Bill No : " + textBox14.Text, new Font("Arial", 15, FontStyle.Bold), Brushes.Black, new Point(510, 220)); //Date e.Graphics.DrawString("Date : " + DateTime.Now, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(510, 250)); //Line e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------- ", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(35, 280)); //Details e.Graphics.DrawString("Particulars", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(35, 300)); e.Graphics.DrawString("HSNCode", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(250, 300)); e.Graphics.DrawString("Unit", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(390, 300)); e.Graphics.DrawString("Batch", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(450, 300)); e.Graphics.DrawString("Qty", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(520, 300)); e.Graphics.DrawString("Exp.", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(570, 300)); e.Graphics.DrawString("Rate", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(645, 300)); e.Graphics.DrawString("Amount", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(720, 300)); //Line e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------- ", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(35, 320)); int yPos = 350; foreach (var i in Product) { e.Graphics.DrawString(i.Particular, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(35, yPos)); e.Graphics.DrawString(i.HSNCode, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(270, yPos)); e.Graphics.DrawString(i.Unit, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(400, yPos)); e.Graphics.DrawString(i.Batch, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(470, yPos)); e.Graphics.DrawString(i.Qty, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(525, yPos)); e.Graphics.DrawString(i.Exp, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(560, yPos)); e.Graphics.DrawString(i.Rate, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(650, yPos)); e.Graphics.DrawString(i.Amount.ToString(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(730, yPos)); yPos += 30; } e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------- ", new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(35, yPos)); e.Graphics.DrawString("SubTotal : " + textBox1.Text.Trim(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(600,yPos+30)); e.Graphics.DrawString("Total to Pay : " + textBox11.Text.Trim(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(600, yPos + 90)); }