Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 985
  • Last Modified:

Can I print Zebra label by other printer?

I need to write a print Zebra label VB program.
However, I haven't the zebra printer on hand.  

Can I print the Label by other printer or preview it on screen?

Thank you.
0
morye
Asked:
morye
  • 9
  • 6
1 Solution
 
PrestaulCommented:
There is not a way to convert ZPL to view on the screen or to send to another printer.  What are you trying to do exactly?  You need to print a label on a Zebra printer but you do not have access to that printer right now?  Your best bet is to get access to that printer so that you can test your code.  If nothing else, send a ZPL file to someone who has a printer and get them to fax you the results.  If you have any questions about ZPL/ZPLII or printing to a Zebra printer then post those questions here and I can help.
0
 
moryeAuthor Commented:
Thank you so much~
0
 
Sangee_CSCCommented:
Hi,

A programmer who used to work in my position created an application in ASP.net & c# (web application) to print a label in zebra printer Ht-146. I am so new to this kind of application and not sure how he did that. I think he used EPL2 programming language to print it. Right now the printer company zebra has discontinued this printer and I am not sure where to get help from. I don't have their programmer's manual to learn the EPL2language. My question is, is there any way that i could preview the label before printing it. Below is the code to print the label:

 
public int printlabel(string field1, string field2){

StringBuilder sb = new StringBuilder(2500);

//O-Hardware oprions. O- Disable all the options

sb.Append("O" + Environment.NewLine);

//Q-will cause the printer to recalculate and reformat the image buffer.

sb.Append("Q1014,1" + Environment.NewLine);

//q-set label width.

sb.Append("q608" + Environment.NewLine);

//S-selects the speed of the printer

sb.Append("S3" + Environment.NewLine);

//D-Print density

sb.Append("D5" + Environment.NewLine);

//Z-Print orientation T-Prining from top of image buffer

sb.Append("ZT" + Environment.NewLine);

//JF-Top of the form back up feature

sb.Append("JF" + Environment.NewLine);

sb.Append(Environment.NewLine);

//N-Clears the image buffer prior to building a new label image

sb.Append("N" + Environment.NewLine);

//LE-Line draw exclusive

sb.Append("LE305,2,1,1013" + Environment.NewLine);

//X-Draws a box shape P1-Horizontal start position P2-Vertical start position P3-Line thickness

//P4-Horizontal end position P5-Vertical end position

sb.Append("X305,507,1,458,1016" + Environment.NewLine);

sb.Append(Environment.NewLine);

sb.Append("X305,0,1,458,509" + Environment.NewLine);

sb.Append(Environment.NewLine);

//A -Command(ASCII), P1-Horizontal start position P2-Vertical Start Position P3-Rotation (3-270 degrees)

//P4 - Font Selection P5- Horizontal multiplier P6 - Vertical multiplier N-Normal or R-Reverse image.

sb.Append("A10,1009,3,3,1,1,N,\"PART NO. AND ITEM DESCRIPTION\"" + Environment.NewLine);

//LE-Line Draw Exclusive P1-Horizontal start position P2-Vertical start posiion P3-Horizontal length in dots

//P4-P4-Vertical length in dots

sb.Append("LE83,38,1,508" + Environment.NewLine);

sb.Append("LE83,38,1,508" + Environment.NewLine);

sb.Append("A109,1010,3,3,1,1,N,\"PN: " + field1 + "\"" + Environment.NewLine);

sb.Append("A133,1010,3,3,1,1,N,\"\"" + Environment.NewLine);

sb.Append("A157,1010,3,3,1,1,N,\"\"" + Environment.NewLine);

sb.Append("A181,1010,3,3,1,1,N,\"" + field2 + "\"" + Environment.NewLine);

sb.Append("A205,1010,3,3,1,1,N,\"\"" + Environment.NewLine);

printString = sb.ToString();

sendBytes = Encoding.ASCII.GetBytes(printString);

strlength = printString.Length;


try

{

TcpClient printer = new TcpClient(ip,portno);

NetworkStream strm = printer.GetStream();

strm.Write(sendBytes, 0, strlength);

strm.Close();

printer.Close();

}

catch (Exception exc)

{

   return -1;

}

   return 1;


}


Can anyone explain me whether there is any way to preview this label before printing it?
Is it possible for me to preview the label just by installing the print driver without the printer itself?
I would really appreciate your help.

NOTE: We have Bar-one software to create the label but not sure how to do that.
Thanks

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
PrestaulCommented:
I'm sorry.  I don't know EPL2, just ZPL2.  I don't believe that you are going to find any way to preview what this code prints, short of installing a printer that can display it.  However, you should be able to determine what EPL2 code it will output and get a good idea of what he is printing.  Here is a link to an EPL2 manual:

http://www.tecno-symbol.com/zebra/zebra_pdf/Line_Mode_Programmers.pdf

This should give you all that you need to determine what he is printing and where.  If you need more than this you should clarify your question.  Are you just trying to see the label?  replace it?  print it on another printer?  What is your end goal?
0
 
Sangee_CSCCommented:
Thanks for the info.

-My primary concern is to add bar codes for the existing fields in the label. I have the printout of the existing label but if i do the changes i would like to preview it than to print each and every time while debugging.

-Do you by any chance know what is the difference between Line mode programming and Page mode programming? Because i have the manual for Page mode and i am not sure whether to follow the manual you gave for line mode or to follow mine.

-Is there any way to create a label using Bar-one software and to convert it to commands that could be used in my application?

Thanks.
0
 
PrestaulCommented:
-I don't think that you'll be able to find a good way to preview the label unless you write it yourself.  (I did something similar to preview labels I was printing using ZPLII)

-I'm not certain,  but I think that the difference between line mode and page mode is that in page mode everything is positioned absolutely (using x/y coordinates).  With line mode you simply output text, labels, etc and it places the text in the next available position as if you were using a word processor.  You can also output carriage returns to advance to the next line.  If your code is intended for the Ht-146 then I think that you want the page mode manual.  Ignore the link I gave...

-I know nothing about Bar-one, but if it outputs EPL2 then you should be able to capture what it is outputting when you try to print.  Ussually software will generate a temp file that holds the EPL2 before it sends it to the printer.  If you monitor the temp directories as you print you may be able to capture this file to see what the EPL2 looks like and use it in your program.  If you cannot catch the file (you should be able to download a file monitor that can catch it) then you could add a fake printer to your machine and pipe the EPL code to a file or display it on the screen.  I think that I could help you with this, but a file monitor would be nicer...

Good luck, and keep me posted on developments.
0
 
PrestaulCommented:
Maybe easier than a file monitor would be a port monitor.  I don't know where your printer is or how it is set up, but you can capture any traffic on that port using a free port monitor as well.  For example:

http://www.softpedia.com/get/Network-Tools/Protocol-Analyzers-Sniffers/Free-Serial-Port-Monitor.shtml

This would allow you to see the EPL2 that the Bar-one program uses.
0
 
PrestaulCommented:
You could also download RedMon.  It is free port redirection software.  I've used it before and it works very well.  You would add a port (RPT1:) using redmon and set up a printer on it using the Zebra printer driver.  Then if you print to that printer it redirects to a file.  This would let you know exactly what Bar-one is sending to the printer (EPL2).
0
 
Sangee_CSCCommented:
Thank you for all your help.
Zebra printer is not connected to my PC since that printer is in our client's place and they are using it right now to print the exisitng label. Do you think that i would need that printer to do the changes or can I just write some code to preview it my PC itself and later transfer the files to the server?

Could you please show some example to write the preview code?  

Thanks again.
0
 
PrestaulCommented:
It would be a great deal of work to write a preview for EPL2.  You would have to write a parser to extract the contents and then write something to render it on the screen.  Not extremely difficult with C# (if that is what you are using) but extremely time consuming.

Do you need a preview just for debugging so that you know what the label you are creating looks like?

If that is all that you need then writing your own preview is too much work.  If you need a preview for your application then it is easier to write a program that displays content before you generate the EPL rather than creating EPL and then parsing it so that you can display it...  This is what I did with my ZPL code.

If your label is similar to the label that is created by the code that you created above (mostly static with only two dynamic elements) then you don't have to worry too much about positioning things dynamically or anything like that.  If you get the layout correct once then you should be ok.  This means that if you can create the label that you need using Bar-one and capture the EPL then you should be able to convert it to code relatively easily.  This is what I would do.  You can be mostly certain that the final label will look (mostly) like the label that you created in Bar-one.

Here's what I would do:
-Install a printer driver for the Zebra printer that you need your code to work with if you don't already have it.
-Download and install RedMon.
-Add a printer using a redirected port (look at RedMon documentation to learn how to do this) and using the Zebra printer driver.
-Create the label that you need using Bar-one.
-Print the label (from Bar-one) to the redirected printer and retrieve the file that is created by RedMon (again, look at RedMon documentation to learn how to get at these files)
-Take that file (it contains the EPL2 to create your label) and modify your code so that it can recreate that file as its output.
-Modify your code so that anything that needs to be dynamic (i.e. PN or whatever) can be set by argument.

I think that you will find this much simpler than trying to write a preview application.

P.S.  What language are you using?
0
 
Sangee_CSCCommented:
Thank you so much for your help.

I am using C# for this application.

I think I am going to download RedMon and follow the steps you have recommended.
Do you think HPLaser Jet would print the Bar codes?
Or do I need to download some fonts for that?

0
 
PrestaulCommented:
An HP LaserJet will print barcodes only if you have a barcode image or a barcode font installed.  Zebra printers have the barcode logic embedded in them.  It is possible that Bar-one has already installed any required fonts or images to print barcodes, but I can't tell you that.  You certainly will not be able to print barcodes on a LaserJet from your own code without a font.
0
 
Sangee_CSCCommented:
I'll look into Bar-one software documentation to see whether they would have installed the fonts necessary for the bar codes or else i'll download it from some websites.

0
 
PrestaulCommented:
What are you trying to do?  What is the goal of this whole excercise?
0
 
Sangee_CSCCommented:
I need to add some more fields and barcodes to the exsisting label.
0
 
PrestaulCommented:
You cannot print EPL2 on your LaserJet.  You may be able to print from Bar-One to your LaserJet, but that will not use EPL, it will use PostScript or PCL.  You cannot modify your code from above to send EPL2 to your HP printer...

Good luck!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 9
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now