471,344 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 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 3238
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by DBQueen | last post: by
3 posts views Thread by Grim Reaper | last post: by
4 posts views Thread by Arif | last post: by
2 posts views Thread by qumpus | last post: by
3 posts views Thread by Rich Kayton | last post: by
reply views Thread by Ronak mishra | last post: by

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.