473,394 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Printing Labels Fast on Elton printer

My program right now generates USPS style shipping label using
System.Drawing.Graphics. It works fine except that the printer prints really
slowly. I want to make my program take advantage of true type fonts. So I
assume it's possible to send Font Type and the text to the printer, and the
printer should digest and print faster. Still, barcode info needs to be sent
as an image.

When I print fifty copies of the same label it prints really fast (cache),
so I guess the printer itself is capable of printing fast.

Any idea's on how can I speed up printing labels using my c# program?

printer specs: http://ups.zebra.com/ctp/prod_2844_specifications.aspx

here is a part of my code:

public void Print()
{
CreatePrintDocument();
printDocument.Print();
}

private void CreatePrintDocument()
{
printDocument = new PrintDocument();
printDocument.DocumentName = "Shipping Labels";
printDocument.BeginPrint += new
PrintEventHandler(printDocument_BeginPrint);
printDocument.PrintPage += new
PrintPageEventHandler(printDocument_PrintPage);

printDocument.DefaultPageSettings.PaperSize =
PageLayout.GetPageSize(settings.LabelLayout);
printDocument.DefaultPageSettings.Margins =
PageLayout.GetPageMargins(settings.LabelLayout);
printDocument.DefaultPageSettings.Landscape =
PageLayout.IsLandScape(settings.LabelLayout);

PrepareDocument();
}

private void PrepareDocument()
{
double labelsCount = Convert.ToDouble(shippingLabels.Count);
double labelsPerPage =
Convert.ToDouble(PageLayout.GetLabelsPerPage(setti ngs.LabelLayout));

pagesCounter =
Convert.ToInt32(Math.Ceiling(labelsCount/labelsPerPage));

printDocument.DefaultPageSettings.PrinterSettings. MinimumPage
= 0;
printDocument.DefaultPageSettings.PrinterSettings. MaximumPage
= pagesCounter;
printDocument.DefaultPageSettings.PrinterSettings. FromPage =

printDocument.DefaultPageSettings.PrinterSettings. MinimumPage;
printDocument.DefaultPageSettings.PrinterSettings. ToPage =

printDocument.DefaultPageSettings.PrinterSettings. MaximumPage;
}

private void printDocument_PrintPage(object sender,
PrintPageEventArgs e)
{
PointF startPoint;

e.Graphics.SetClip(e.MarginBounds);
startPoint = new PointF(e.PageSettings.Margins.Left,
e.PageSettings.Margins.Top);
DrawShippingLabel_Label_4_8(e.Graphics, startPoint,
this.Labels[labelIndex]);}
}

private void DrawShippingLabel_Label_4_6(Graphics graphics, PointF
startPoint, ShippingLabel shippingLabel)
{
Pen drawPen;
Font drawFont;
Rectangle rectangle;
Margins margins;

Rbarcode1D barCode;

string drawString;
string[] drawText;

graphics.TranslateTransform(startPoint.X, startPoint.Y);

//Begin: Generating EAN128\subset C barcode
barCode = new Rbarcode1D();
if(shippingLabel.shippingMethod !=
OrderShippingMethod.International_DHL)
{
switch(settings.BarcodeType)
{
case BarcodeTypes.BAR39: barCode.BarType
= Rbarcode1D.BAR39; break;
case BarcodeTypes.BAR39EXT:
barCode.BarType = Rbarcode1D.BAR39EXT; break;
case BarcodeTypes.CODABAR:
barCode.BarType = Rbarcode1D.CODABAR; break;
case BarcodeTypes.CODE11:
barCode.BarType = Rbarcode1D.CODE11; break;
case BarcodeTypes.CODE128:
barCode.BarType = Rbarcode1D.CODE128; break;
case BarcodeTypes.CODE93:
barCode.BarType = Rbarcode1D.CODE93; break;
case BarcodeTypes.CODE93EXT: barCode.BarType =
Rbarcode1D.CODE93EXT; break;
case BarcodeTypes.EAN128:
barCode.BarType = Rbarcode1D.EAN128; break;
case BarcodeTypes.EAN13: barCode.BarType
= Rbarcode1D.EAN13; break;
case BarcodeTypes.EAN8:
barCode.BarType = Rbarcode1D.EAN8; break;
case BarcodeTypes.IND25: barCode.BarType
= Rbarcode1D.IND25; break;
case BarcodeTypes.MAT25: barCode.BarType
= Rbarcode1D.MAT25; break;
case BarcodeTypes.MSI:
barCode.BarType = Rbarcode1D.MSI; break;
case BarcodeTypes.POSTNET:
barCode.BarType = Rbarcode1D.POSTNET; break;
case BarcodeTypes.UPCA:
barCode.BarType = Rbarcode1D.UPCA; break;
case BarcodeTypes.UPCE:
barCode.BarType = Rbarcode1D.UPCE; break;
}
barCode.BarCode128Set = (char) settings.Barcode128Set;
barCode.BarCheckCharacter = settings.BarCheckCharacter;
barCode.BarDrawText = false;
barCode.BarleftMargin = 0;
barCode.BartopMargin = 0;
barCode.Nsize = 1;
barCode.Xsize = 1;
barCode.BarHeight = 70;
barCode.BarguardBars = true;
barCode.Data =
shippingLabel.BarCodeData.Replace(" ", "");
//End: Generating EAN128\subset C barcode

//Begin: Drawing a barcode
drawString = "e/ USPS DELIVERY CONFIRM";

drawFont = new Font("Sans Serif", 12, FontStyle.Bold);

graphics.TranslateTransform(4, 95 +
graphics.MeasureString(drawString, drawFont).Height + 15,
System.Drawing.Drawing2D.MatrixOrder.Append);

graphics.ScaleTransform(2.0F, 1.0F);
barCode.paintBarcode(graphics);

graphics.ResetTransform();
//End: Drawing a barcode

graphics.TranslateTransform(startPoint.X, startPoint.Y);

//Begin: Drawing other parts of the barcode
drawPen = new Pen(Brushes.Black, 6);

graphics.DrawLine(drawPen, 0, 100, 380, 100);
graphics.DrawLine(drawPen, 0, 230, 380, 230);
graphics.DrawString(drawString, drawFont, Brushes.Black,
GetCentreXCoordinate(0, 380,
Convert.ToInt32(graphics.MeasureString(drawString, drawFont).Width)),
105);

drawFont.Dispose();
drawPen.Dispose();

drawFont = new Font("Sans Serif", 12, FontStyle.Bold);

drawString = shippingLabel.BarCodeData;

graphics.DrawString(drawString, drawFont, Brushes.Black,
GetCentreXCoordinate(0, 380,
Convert.ToInt32(graphics.MeasureString(drawString, drawFont).Width)),
205);

drawFont.Dispose();
//End: Drawing other parts of the barcode

}

//Begin: Drawing Return Address
drawFont = new Font("Times New Roman", 12);

rectangle = new Rectangle(new Point(0, 0), new Size(300, 0));
margins = new Margins(5, 5, 5, 5);

drawText = new string[4];
drawText[0] = shippingLabel.CompanyName;
drawText[1] = shippingLabel.CompanyAddress;
drawText[2] = shippingLabel.CompanyCity + ", " +
shippingLabel.CompanyState
+ " " + shippingLabel.CompanyZipCode.ToUpper();
drawText[3] = shippingLabel.CompanyEMail;

DrawTextInRectangle(graphics, Brushes.Black, null, drawFont,
drawText, ref rectangle, margins, true);

drawFont.Dispose();
//End: Drawing Return Address

//Begin: Drawing SKUs and order number for specified order
drawText = new string[5];
drawText[0] = DateTime.Now.ToString();
drawText[1] = "";
drawText[2] = "NUM: ";
foreach(string SKU in shippingLabel.SKUs)
{
drawText[2] += " " + SKU;
}
drawText[3] = "";
drawText[4] = "Order #" + shippingLabel.OrderNumber;

rectangle = new Rectangle(new Point(0, 240), new Size(380, 0));
margins = new Margins (10, 10, 10, 10);

drawFont = new Font("Times New Roman", 12);
drawPen = new Pen(System.Drawing.Color.Black, 2);

DrawTextInRectangle(graphics, Brushes.Black, drawPen,
drawFont, drawText, ref rectangle, margins, false);

drawPen.Dispose();
drawFont.Dispose();
//End: Drawing SKUs and order number for specified order

//Begin: Drawing Customer information
drawFont = new Font("Times New Roman", 16);

//This position is calculating depending on previous rectangle!
rectangle = new Rectangle(new Point(0, rectangle.Top +
rectangle.Height), new Size(380, 0));
margins = new Margins(0, 0, 10, 10);

drawText = new string[4];
drawText[0] = shippingLabel.CustomerName;
drawText[1] = shippingLabel.AddressLine1;
drawText[2] = shippingLabel.AddressLine2;
drawText[3] = shippingLabel.City + ", " + shippingLabel.State
+ " " + shippingLabel.ZipCode.ToUpper();
DrawTextInRectangle(graphics, Brushes.Black, null, drawFont,
drawText, ref rectangle, margins, true);
//Begin: Drawing a "Do Not Bend" string

drawString = "Do Not Bend";

drawFont = new Font("Sans Serif", 36, FontStyle.Bold);
graphics.DrawString(drawString, drawFont, Brushes.Black,
GetCentreXCoordinate(0, 380,
Convert.ToInt32(graphics.MeasureString(drawString, drawFont).Width)),
500);
drawFont.Dispose();
//End: Drawing a "Do Not Bend" string

drawFont.Dispose();
barCode.Dispose();

graphics.ResetTransform();
}

Jul 21 '05 #1
2 3417
On Mon, 13 Jun 2005 10:41:04 -0700, qumpus wrote:
My program right now generates USPS style shipping label using
System.Drawing.Graphics. It works fine except that the printer prints really
slowly. I want to make my program take advantage of true type fonts. So I
assume it's possible to send Font Type and the text to the printer, and the
printer should digest and print faster. Still, barcode info needs to be sent
as an image.
Absolutely not true. The Eltron printers have barcode-generation logic
built in. For example, sending this string to the printer:

"N" + chr(13) + "B10,10,0,3,3,7,200,B,""998152-001""" + chr(13) + "P1" +
chr(13)

would produce a Code 39 barcode starting at 10 dots down, 10 dots from left
margin, with a height of 200 dots.
Any idea's on how can I speed up printing labels using my c# program?

printer specs: http://ups.zebra.com/ctp/prod_2844_specifications.aspx


See http://www.ptshome.com/public/EPL2en.pdf
Jul 21 '05 #2
Thanks,

Let me try this and I'll write you back if I got it to work.
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DBQueen | last post by:
I have a database which will be printing out labels for SMALL test tubes (1/4" high). We have yet to find a reasonably-priced printer (labelwriter) which can effectively print this on ROLLS of...
3
by: Grim Reaper | last post by:
I print mailing labels out of Access 2000 databases about 3 to 4 times a week. I have been having problems with one thing since I have been printing mailing labels. I print mailing labels by...
4
by: Arif | last post by:
I C# code prints very slow as compared to a third party barcode printing software. That software prints approximately 10 labels in 2 seconds while my C# code prints 10 labels in 5 to 6 seconds. And...
3
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
2
by: qumpus | last post by:
My program right now generates USPS style shipping label using System.Drawing.Graphics. It works fine except that the printer prints really slowly. I want to make my program take advantage of true...
6
by: Ron | last post by:
Hi, I know Access allows for easy construction of a report setup to print labels from a table/query, etc. I've done that one. It works pretty well for what I need. However, is there an...
3
by: Rich Kayton | last post by:
I have an application that is currently a DBASE/Clipper application. We print out a variety of custom labels on Epson DOT matrix printers. I would like to be able to print these labels. I am...
0
by: jinsatoemo | last post by:
Hello guys,i'm new here,nice to meet you all :-) I need some help in access,particularly in printing to label printers.I've developed a program that generate labels to print to a label...
5
by: Ron | last post by:
Hi All, I've got a report that prints mailing labels. It utilizes a routine that asks the number of labels to skip, the number of each label to print, and then prints. It works really well on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.