This code is working great but The code print the text in simple font but I want to print it in dot matrix font , any code to print it in dot matrix?
try
{
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings.PaperSize = new PaperSize("A4", 827, 1170);
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}
catch (Exception ex)
{
MessageBox.Show("پیج کو پرنٹ کرتےوقت ایرر آگیا", ex.ToString());
}
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString(textBox1.Text.ToString(), new Font("BroadWay", 18,
FontStyle.Bold), Brushes.Black, 14,95);
e.Graphics.DrawString(textBox2.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 12, 165);
e.Graphics.DrawString(textBox3.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 12, 265);
e.Graphics.DrawString(textBox4.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 346, 96);
e.Graphics.DrawString(textBox5.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 285, 165);
e.Graphics.DrawString(textBox6.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 285, 229);
e.Graphics.DrawString(textBox7.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 285, 287);
e.Graphics.DrawString(textBox8.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 146, 326);
e.Graphics.DrawString(textBox9.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 742, 96);
e.Graphics.DrawString(textBox10.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 634, 144);
e.Graphics.DrawString(textBox11.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 634, 215);
e.Graphics.DrawString(textBox12.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 634, 266);
e.Graphics.DrawString(textBox13.Text.ToString(), new Font("BroadWay", 18, FontStyle.Bold), Brushes.Black, 238, 382);
e.Graphics.DrawString(textBox14.Text.ToString(), new Font("BroadWay", 12, FontStyle.Regular), Brushes.Black, 388, 421);
}
The code is working great but only i want now to print it in dot matrix font
that not yet done . i hope one of you will help me
my printer is LX-300+ II Impact Printer
i have no idea what to do now!
I have no experience with arabic (or whatever that language is) but, simply setting the font to "Courier New" usually solves that problem. You might have to convert text encoding to ansi from unicode.
Related
I am getting this error:
TicketingSystem' does not contain a definition for 'DVPrintDocument_PrintPage' and no extension method could be found.
I am trying to organize my code by putting it in separate classes. I made a new class called Printing.cs which has this code:
public void DVPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap r3tsLogo = Properties.Resources.rt3slogo;
Image image1 = r3tsLogo; //image 1 is r3tsLogo
e.Graphics.DrawImage(image1, 350, 0, image1.Width, image1.Height);
// e.Graphics.DrawString("Employee Name:" + employee.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 200)); //Put to bottom of paper
e.Graphics.DrawString("Address:", new Font("Impact", 12, FontStyle.Regular), Brushes.Black, new Point(300, 90));//change the new point to put text on different part of paper.
e.Graphics.DrawString("North Building", new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(370, 94)); //This line of code connects to Code line 151
e.Graphics.DrawString("Email:", new Font("Impact", 12, FontStyle.Regular), Brushes.Black, new Point(300, 120));//change the new point to put text on different part of paper.
e.Graphics.DrawString("email#email.com", new Font("Arial", 10, FontStyle.Regular), Brushes.Black, new Point(350, 124)); //This line of code connects to Code line 154
e.Graphics.DrawString("Date: " + DateTime.Now, new Font("Arial", 13, FontStyle.Regular), Brushes.Black, new Point(300, 150));
e.Graphics.DrawString(ticketingSystem.dashes.Text, new Font("Arial", 12), Brushes.Black, new Point(0, 160));
e.Graphics.DrawString("CUSTOMER INFORMATION:", new Font("Arial", 14, FontStyle.Regular), Brushes.Black, new Point(275, 180));
e.Graphics.DrawString("Customer Name:" + ticketingSystem.nameTxtB.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 200));
e.Graphics.DrawString("Email:" + ticketingSystem.emailTxtBox.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 230));
e.Graphics.DrawString("Cell Number:" + ticketingSystem.cellNumberTxtB.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 260));
if(ticketingSystem.studentRadioB.Checked == true)
{
e.Graphics.DrawString("Position:" + ticketingSystem.studentRadioB.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 290));
}
else if (ticketingSystem.teacherRadioB.Checked == true)
{
e.Graphics.DrawString("Position:" + ticketingSystem.teacherRadioB.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 290));
}
e.Graphics.DrawString(ticketingSystem.dashes.Text, new Font("Arial", 12), Brushes.Black, new Point(0, 350));
//--------------------------------------Device Information -------------------------------------------------------------------------------------
int y = 493;
e.Graphics.DrawString("DEVICE INFORMATION:", new Font("Arial", 14, FontStyle.Regular), Brushes.Black, new Point(286, 373));
e.Graphics.DrawString("Device Type:" + ticketingSystem.devices.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 403));
if (ticketingSystem.devices.Visible == true & ticketingSystem.devices.Text == "Console")
{
e.Graphics.DrawString("Type of Console:" + ticketingSystem.consoleTextBox.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 433));
}
if (ticketingSystem.comboBox3.Visible == true) //iphone selection box is visible then show selected model on print document
{
e.Graphics.DrawString("Type of Phone:" + ticketingSystem.comboBox3.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 433));
}
e.Graphics.DrawString("Service Type:" + ticketingSystem.serviceDesc.Text, new Font("Arial", 15, FontStyle.Regular), Brushes.Black, new Point(50, 463));
using (var arial15 = new Font("Arial", 15, FontStyle.Regular))
{
y += DrawWrapped("Price: $" + Convert.ToInt32(cPrice), arial15, new Point(50, 493), e.PageBounds.Size, e.Graphics);
}
using (var arial15 = new Font("Arial", 15, FontStyle.Regular))
{
y += DrawWrapped("Description:" + ticketingSystem.description4Repair.Text, arial15, new Point(50, y), e.PageBounds.Size, e.Graphics);
}
}
Now when I comment everything out in my Main.cs I get the same error:
TicketingSystem' does not contain a definition for 'DVPrintDocument_PrintPage' and no extension method could be found.
All I want to do is tell my designer.cs to look for the code in Printing.cs.
I have a problem with my c# application, because i need to print with dot matrix printer "Olivetti PR2 Plus" using X and Y Position coordinates, like VB6 did. the problem is if the string have more than 20 characters aprox, the printer is very slow and i need to print fast.
I have the following code for testing purposes and have the problem.
private void btnPrint_Click(object sender, EventArgs e)
{
Document = new PrintDocument();
Document.PrintPage += Document_PrintPage;
Document.PrinterSettings.PrinterName = ((ICollection)PrinterSettings.InstalledPrinters).OfType<string>().Where(p => p.ToUpper().Contains("OLIVETTI")).First().ToString();
Document.Print();
}
private void Document_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString("asdfasdfasdfasdasdffasdfasdfasdf", new Font("Consolas", 8), Brushes.Black, 20, 0, new StringFormat());
e.Graphics.DrawString("asdfasdfasdasdaasdfsdfffasdfasdf", new Font("Consolas", 8), Brushes.Black, 20, 10, new StringFormat());
e.Graphics.DrawString("asdfasdfaasdfsasdfsadfdfasdfasdf", new Font("Consolas", 8), Brushes.Black, 20, 20, new StringFormat());
e.Graphics.DrawString("asfdasdfsadfasasdfasdfdasdfasdff", new Font("Consolas", 8), Brushes.Black, 20, 30, new StringFormat());
e.Graphics.DrawString("asfdasdsdafasadfsasdfdasdfasdfff", new Font("Consolas", 8), Brushes.Black, 20, 40, new StringFormat());
e.Graphics.DrawString("asdfaasdsadfsadffsadfsdassadfdff", new Font("Consolas", 8), Brushes.Black, 20, 50, new StringFormat());
e.Graphics.DrawString("asfdasdfsdafsadfsadfasasasdfdfdf", new Font("Consolas", 8), Brushes.Black, 20, 60, new StringFormat());
e.Graphics.DrawString("asdfasadfassadfdfssadfassadfdfdf", new Font("Consolas", 8), Brushes.Black, 20, 70, new StringFormat());
e.Graphics.DrawString("asfdasadfasadfsdfssadasasdffdfdf", new Font("Consolas", 8), Brushes.Black, 20, 80, new StringFormat());
}
I can't print in RAW "DOS" mode because the source of the data to print have specific coordinates for match with the paper formats. ¿any sugestion to improve the perfomance of the printer?
In my Windows application, I print multiple items in my PrintPriview control but when the items are more than 25, it doesn't go the next page to print the rest of the items. I know that we need to use e.Hasmorepages = true but I can't figure out how to use it correctly. Please help.
Screen shot -
Click here to see screen shot
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bmp = Properties.Resources.logo2;
Image image = bmp;
e.Graphics.DrawImage(image, 0, 0, image.Width, image.Height);
e.Graphics.DrawString("Date: " + DateTime.Now.ToShortDateString(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, 160));
e.Graphics.DrawString("Client Name: " + ClientNameTextBox.Text.Trim(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, 190));
e.Graphics.DrawString("------------------------------------------------------------------------------------------------------------------------------------", new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, 235));
e.Graphics.DrawString("Item Name", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(30, 255));
e.Graphics.DrawString("Quantity", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(380, 255));
e.Graphics.DrawString("Unit Price (£)", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(510, 255));
e.Graphics.DrawString("Total Price (£)", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(660, 255));
e.Graphics.DrawString("------------------------------------------------------------------------------------------------------------------------------------", new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, 270));
int yPos = 295;
foreach (var i in shoppingCart)
{
e.Graphics.DrawString(i.ItemName, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(30, yPos));
e.Graphics.DrawString(i.Quantity.ToString(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(400, yPos));
e.Graphics.DrawString(i.UnitPrice.ToString(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(550, yPos));
e.Graphics.DrawString(i.TotalPrice.ToString(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(700, yPos));
yPos += 30;
}
e.Graphics.DrawString("------------------------------------------------------------------------------------------------------------------------------------", new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, yPos));
e.Graphics.DrawString("Total Amount: £" + TotalAmountTextBox.Text.Trim(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(550, yPos + 30));
e.Graphics.DrawString("Sales Tax (16%): £" + SalesTaxTextBox.Text.Trim(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(550, yPos + 60));
e.Graphics.DrawString("Total To Pay: £" + TotalToPayTextBox.Text.Trim(), new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(550, yPos + 90));
e.Graphics.DrawString("------------------------------------------------------------------------------------------------------------------------------------", new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, yPos + 120));
}
Thanks in advance.
Regards,
Yes, you need to
a) watch the y value
b) set HasMorePages to true when it is over a maximum page height value
c) leave the printpage event.
It'll be called again if needed, ie when you either print or preview the next page..
You also need to keep track of the cart items you have printed in a class level variable; replace the foreach by a for loop storing/using that item number! Break out of the loop and later also return from the event when y is larger than the maximum that will fit on your page!
Also design for repeating the headers, but you got that right I think! Finally another class level variable should keep track of the page numbers!
Working on a project that requires me to create a shipping label and store it as PNG. I've setup the layout and everything looks good when I view the PNG file, but when I go to print on the thermal/ink jet/laser printer the quality is horrible.
I've searched all over but I can't find anything that seems to address my issue. I'm not a graphics person but I'm wondering if I need to build the file in a higher resolution, but the end result needs to be a 4 by 6 shipping label. What is the best method to improve the image quality?
Below is the code that is used to generate PNG file:
Bitmap bitMapImage = new System.Drawing.Bitmap("blanklabel.png");
Graphics graphicImage = Graphics.FromImage(bitMapImage);
graphicImage.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
string dttime = DateTime.Now.ToString("HHmmss");
// Create pen.
Pen blackPen0 = new Pen(Color.Gray, 1);
Pen blackPen1 = new Pen(Color.Black, 1);
Pen blackPen2 = new Pen(Color.Black, 2);
Pen blackPen3 = new Pen(Color.Black, 3);
//Top Rectangle - Draw Box
Rectangle topRect = new Rectangle(5, 5, 367, 338);
graphicImage.DrawRectangle(blackPen1, topRect);
//Top Rectangle - Horizontial Lines
graphicImage.DrawLine(blackPen1, 5, 41, 372, 41);
graphicImage.DrawLine(blackPen1, 5, 77, 372, 77);
graphicImage.DrawLine(blackPen2, 5, 129, 372, 129);
graphicImage.DrawLine(blackPen2, 5, 210, 372, 210);
graphicImage.DrawLine(blackPen0, 5, 225, 372, 225); //Draw row1 in middle
graphicImage.DrawLine(blackPen0, 5, 240, 372, 240); //Draw row2 in middle
graphicImage.DrawLine(blackPen0, 5, 255, 372, 255); //Draw row3 in middle
graphicImage.DrawLine(blackPen1, 5, 271, 372, 271);
graphicImage.DrawLine(blackPen1, 5, 322, 372, 322);
//Top Rectangle - Vertical Lines
graphicImage.DrawLine(blackPen1, 258, 41, 258, 322);
graphicImage.DrawLine(blackPen1, 103, 210, 103, 271);
graphicImage.DrawLine(blackPen1, 172, 210, 172, 271);
//graphicImage.DrawLine(blackPen1, 257, 210, 257, 271);
graphicImage.DrawLine(blackPen1, 304, 210, 304, 271);
//Top Rectangle - Label Text
graphicImage.DrawString("Shipper's Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 43));
graphicImage.DrawString("Receiver's Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 79));
graphicImage.DrawString("Origin", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 43));
graphicImage.DrawString("Destination", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 79));
graphicImage.DrawString("Time-definite type", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 131));
graphicImage.DrawString("Total packages", new Font("Arial", 6), SystemBrushes.WindowText, new Point(10, 213));
graphicImage.DrawString("Total Actual weight", new Font("Arial", 6), SystemBrushes.WindowText, new Point(10, 228));
graphicImage.DrawString("Total Chargeable weight", new Font("Arial", 6), SystemBrushes.WindowText, new Point(10, 243));
graphicImage.DrawString("Freight Charges", new Font("Arial", 6), SystemBrushes.WindowText, new Point(10, 258));
graphicImage.DrawString("Additional Service", new Font("Arial", 6), SystemBrushes.WindowText, new Point(180, 213));
graphicImage.DrawString("Charges", new Font("Arial", 6), SystemBrushes.WindowText, new Point(264, 213));
graphicImage.DrawString("Total Charges", new Font("Arial", 6), SystemBrushes.WindowText, new Point(310, 213));
graphicImage.DrawString("Payment Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 275));
graphicImage.DrawString("Credit Account No.:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 290));
graphicImage.DrawString("3rd Party District code:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 305));
graphicImage.DrawString("Receiver's Signature:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 275));
graphicImage.DrawString("Delivery Date:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 305));
graphicImage.DrawString("Remarks:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 327));
//Bottom Rectangle - Draw Box
Rectangle bottomRect = new Rectangle(5, 349, 367, 211);
graphicImage.DrawRectangle(blackPen1, bottomRect);
//Bottom Rectangle - Horizontial Lines
graphicImage.DrawLine(blackPen1, 258, 377, 372, 377);
graphicImage.DrawLine(blackPen1, 5, 401, 258, 401);
graphicImage.DrawLine(blackPen1, 5, 468, 372, 468);
graphicImage.DrawLine(blackPen1, 5, 528, 372, 528);
//Bottom Rectangle - Vertical Lines
graphicImage.DrawLine(blackPen1, 258, 349, 258, 560);
//Bottom Rectangle - Label Text
graphicImage.DrawString("Shipment Type:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 352));
graphicImage.DrawString("Description of Contents:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 380));
graphicImage.DrawString("Declared value for Customs:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 420));
graphicImage.DrawString("Country of Origin:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 450));
graphicImage.DrawString("Shipper's Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 404));
graphicImage.DrawString("Receivers's Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 471));
graphicImage.DrawString("Total Charges:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 471));
graphicImage.DrawString("Payment Information:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 495));
graphicImage.DrawString("Customer remarks:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 538));
//Bottom Rectangle - Self Drop Selection Box
Rectangle bottomselectRect1 = new Rectangle(261, 538, 12, 12);
graphicImage.DrawRectangle(blackPen1, bottomselectRect1);
//Bottom Rectangle - Self Pickup Selection Box
Rectangle bottomselectRect2 = new Rectangle(313, 538, 12, 12);
graphicImage.DrawRectangle(blackPen1, bottomselectRect2);
graphicImage.DrawString("Self-drop:", new Font("Arial", 5), SystemBrushes.WindowText, new Point(276, 541));
graphicImage.DrawString("Self-pickup:", new Font("Arial", 5), SystemBrushes.WindowText, new Point(328, 541));
HttpContext.Current.Response.ContentType = "image/png";
bitMapImage.Save("test_label_" + dttime + ".png", ImageFormat.Png);
blackPen0.Dispose();
blackPen1.Dispose();
blackPen2.Dispose();
blackPen3.Dispose();
graphicImage.Dispose();
bitMapImage.Dispose();
This is only a partial answer, but it may help. Here is what your image is:
Image Dinensions: 377 x 566 Pixels
10.19 x 15.30 Cm
Pixels Per cm: 37
It might help to know what your output device(s) use, but most inkjet printers I have used are happy with 300 pixels per inch (or some multiple of 300 dpi). Other resolutions would have to be scaled, which could be disastrous for such fine detail.
Do you have a graphics program you can use to modify the resolution and scaling of your PNG so you can experiment without having to keep changing your program? (I'm using an ancient version of the no-longer-available Paint Shop Pro, but I also have Corel Photo Paint which would also do the job.) If you don't have anything, you might try gimp (free bitmap software).
I fill up a datagridview and after that I print out the list from there some extra fix string fields. The first two printing finishing fast but after that 3-4 is slowing down very much(sometimes it freezing).
I think some buffer or something fills up and i have to empty it but how? If I tried to print via pdf printer the first file size is normal ~200KB second is 1MB and the third is 4-6MB the fourth is so big it is freezing.
It is only one page maximum two page long list. Can someone help me to find the problem and offer a solution or more?
private void button1_Click(object sender, EventArgs e)
{
printDocument1.Print();
}
Print button
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bmp = Properties.Resources.ugro;
Image newImage = bmp;
e.Graphics.DrawImage(newImage, 700, 20, 100, 100);
Bitmap bmp1 = Properties.Resources.line_1;
Image newImage1 = bmp1;
e.Graphics.DrawImage(newImage1, 20, 80, 700, 1);
e.Graphics.DrawString("Text", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(280, 20));
e.Graphics.DrawString(lbl_datum.Text, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, new Point(20, 20));
// e.Graphics.DrawString("Text:", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(20, 100));
//e.Graphics.DrawString(txt_BID.Text, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(160, 80));
//e.Graphics.DrawString(txt_ID.Text, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(160, 100));
DataGridViewCell cell = null;
foreach (DataGridViewCell selectedCell in dataGridView1.SelectedCells)
{
cell = selectedCell;
break;
}
if (cell != null)
{
DataGridViewRow row = cell.OwningRow;
}
e.Graphics.DrawString("Name", new Font("Arial", 10, FontStyle.Bold), Brushes.Black, new Point(40, 60));
e.Graphics.DrawString("Height(cm)", new Font("Arial", 10, FontStyle.Bold), Brushes.Black, new Point(150, 60));
e.Graphics.DrawString("Weight(kg)", new Font("Arial", 10, FontStyle.Bold), Brushes.Black, new Point(280, 60));
e.Graphics.DrawString("Text(cm)", new Font("Arial", 10, FontStyle.Bold), Brushes.Black, new Point(410, 60));
int height = 0;
//int width = 0;
//e.Graphics.FillRectangle(Brushes.DarkGray,new Rectangle(100,100,dataGridView1.Columns[0].Width,dataGridView1.Rows[0].Height));
// e.Graphics.DrawString(dataGridView1.Columns[0].HeaderText.ToString(), new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Rectangle(420, 80, dataGridView1.Columns[0].Width,dataGridView1.Rows[1].Height));
height = 80;
while (i < dataGridView1.Rows.Count)
{
if (height > e.MarginBounds.Height)
{
e.HasMorePages = true;
return;
}
height += 20;
//e.Graphics.DrawString(dataGridView1.Rows[i].Cells[0].FormattedValue.ToString(), dataGridView1.Font, Brushes.Black, new Rectangle(20, height, dataGridView1.Columns[0].Width, 20));
e.Graphics.DrawString(dataGridView1.Rows[i].Cells[0].FormattedValue.ToString(), dataGridView1.Font, Brushes.Black, new Rectangle(20, height, dataGridView1.Columns[0].Width+50, 40));
string sign = String.Format("_____________");
e.Graphics.DrawString(sign, dataGridView1.Font, Brushes.Black, new Rectangle(150, height, dataGridView1.Columns[0].Width + 100, 40));
e.Graphics.DrawString(sign, dataGridView1.Font, Brushes.Black, new Rectangle(280, height, dataGridView1.Columns[0].Width + 100, 40));
e.Graphics.DrawString(sign, dataGridView1.Font, Brushes.Black, new Rectangle(410, height, dataGridView1.Columns[0].Width + 100, 40));
i++;
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
}
i = 0;
}
Which variable is causing my problem?