Sorry to bring up an old thread, but I want to commend gkheng2003 for sticking to his guns. I have been using a solution just like what he is after and am trying to duplicate it which proves extremely hard since all I end up with is the "it can't be done"
people as well. it can and I am willing to prove it for anyone who wants to see. just reply to this thread and I will set up my server and post the link.
I have finally found a solution using javascript and zpl on my aspx page, I will post the page code later, just keep in mind its kind of a mess since it was just a test page
My problem is that we are rendering an RDL, then export it as PNG to server, update an image link for the browser and then send it to a default printer (in this case a docket printer Zebra LP2824)... anyway, here is the ActiveX control. Note that most dudes,
when they say Create your own ActiveX typically haven't done it before. Unfortunately, we have moved from an Application based program to Web App and the chap that ships products with docket stickers on them still has to wait for the whole rendering process
where as before it only took .5 seconds now takes up to 6. Big change when you are shippping 200 items.
<head runat="server">
<title>Docket Printer</title>
<script language="vbscript" type="text/vbscript">
Sub Print()
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>
<base target="_self" />
</head>
so calling Print() *should* print it automagically, in IE. Also there's an option to print in
FireFox without having the print prompt jump up and send to default. Unfortunately Gov is thumbed on IE, a little annoying!
but if you have another option that could be quicker I would love to see it!...
I use this to print simple labels for work and use java to create and call print on a page, I have used it on IE 6,7, and 8 it did not work on 9 and I haven't tried it with other browsers yet, This isn't very pretty but it works, also I had to break up the
java function to get it all here so you may need to make the area 1 line again. Here it is.
Thanks for quick reply maddmike..... I had gone down that road too. A good solution. However, if you have a network printer there's an even better solution, and can be ascy using webservices ...using libraries System.Data, System.Net.Sockets, the bonus is
I don't neet to have pop-ups, or render further pages. Works well... Credit to the person I knabbed the idea from, cant' remember where though... but my friday is now a treat!
Thanks again
public void Run_PrintDocket(PART_SERVICE_TRANSACTION _ToPrint)
{
// Build output string - Example - Printer Settings
//strPrintOutput = BuildString1();
// Build output string - Example - Print Label with Barcode and some text (Prints two labels)
string strPrintOutput = BuildString2("123456", "2010-01-02", "1234567890", "123", "Harddrive", "D31", "123456", "2");
// Send output to Zebra Printer
// 9100 = The default printer port, but that could be changed on the printer
// For external access (e.g. through the internet) you need to use the IP/domain name of the router/firewall and also open a port in the firewall and forward the traffic to the internal IP and port set on the printer
// Note that for external access appropriate security measures should be added in some way.
Connect("10.80.8.65", 9100, strPrintOutput); //(IP, Port,stin
}
public void Connect(String ip, Int32 port, String strMessage)
{
try
{
// Convert String to Byte Array with encoding Windows-1252
//Byte[] data = System.Text.Encoding.ASCII.GetBytes(strMessage);
Byte[] data = System.Text.Encoding.GetEncoding(1252).GetBytes(strMessage);
// Create connection to printer
TcpClient printer = new TcpClient(ip, port);
// Get stream object of printer
NetworkStream strm = printer.GetStream();
// Write message to stream
strm.Write(data, 0, data.Length);
// Status Message
//Console.WriteLine("Sent: {0}", strMessage);
// Close stream
strm.Close();
//Close connection to printer
printer.Close();
} // end try
catch (ArgumentNullException e)
{
//Console.WriteLine("ArgumentNullException: {0}", e);
}
catch (SocketException e)
{
//Console.WriteLine("SocketException: {0}", e);
}
//Console.WriteLine("\n Press Enter to continue...");
//Console.Read();
}
/*
* \n = LF (Line Feed)
* \r = CR (Carriage Return)
* \r\n = CrLf
* Printer ignores CR when sent
* CR cannot be used in place of LF
*/
public String BuildString1()
{
StringBuilder sb = new StringBuilder();
//Clears out printer buffer
sb.Append("\n");
//Print the current printer configuration
sb.Append("U\n");
return sb.ToString();
}
public String BuildString2(String strBarCode, String strDate, String strArticleNumber, String strPurchaseOrderNumber, String strArticleName, String strLocation, String strOrderNumber, String strNoOfLabels)
{
StringBuilder sb = new StringBuilder();
//Clears out printer buffer
sb.Append("\n");
//Clears out the image buffer
sb.Append("Heath autoprinting\n");
//Set 8-bit, CodePage Windows 1252 (Latin 1), KDU Sweden (Printer with display)
sb.Append("Test\n");
// Create Print Objects
return sb.ToString();
}
With our setup this is used on 12 different computers with 12 printers so it turned out to be the best solution here, I just found it odd that nothing would print with IE9.
Has anyone come up with a solution for IE9?
I have tried in IE9, Chrome and Firefox with no luck on a local Zebra printer.
I have attempted to 'restore previous version' but with no luck. My operating system shipped with 9.
alberto_rroc...
Member
2 Points
1 Post
Re: Printing to a Zebra label printer 105SL
Mar 01, 2010 08:11 PM|LINK
hello, gkheng2003
I have the same problem. What was the solution you found, could I pass, I would be very grateful.
gkheng2003
Member
2 Points
11 Posts
Re: Printing to a Zebra label printer 105SL
Mar 02, 2010 12:29 AM|LINK
hopefully it's this could solve your problem:
http://start-coding.blogspot.com/2010/02/print-zebra-barcode-label-thru-asp-net.html
vutlaphani
Member
4 Points
2 Posts
Re: Printing to a Zebra label printer 105SL
Sep 22, 2010 03:56 PM|LINK
Did u got any solution for this problem,if you got can you please send me the solution
maddmike71
Member
73 Points
54 Posts
Re: Printing to a Zebra label printer 105SL
Feb 22, 2011 05:37 AM|LINK
Sorry to bring up an old thread, but I want to commend gkheng2003 for sticking to his guns. I have been using a solution just like what he is after and am trying to duplicate it which proves extremely hard since all I end up with is the "it can't be done" people as well. it can and I am willing to prove it for anyone who wants to see. just reply to this thread and I will set up my server and post the link.
Mike
maddmike71
Member
73 Points
54 Posts
Re: Printing to a Zebra label printer 105SL
Feb 24, 2011 06:00 AM|LINK
beaphy
Member
4 Points
4 Posts
Re: Printing to a Zebra label printer 105SL
Jun 23, 2011 10:49 PM|LINK
Gimme Gimme :)
There's already activeX control built into IE
My problem is that we are rendering an RDL, then export it as PNG to server, update an image link for the browser and then send it to a default printer (in this case a docket printer Zebra LP2824)... anyway, here is the ActiveX control. Note that most dudes, when they say Create your own ActiveX typically haven't done it before. Unfortunately, we have moved from an Application based program to Web App and the chap that ships products with docket stickers on them still has to wait for the whole rendering process where as before it only took .5 seconds now takes up to 6. Big change when you are shippping 200 items.
<head runat="server">
<title>Docket Printer</title>
<script language="vbscript" type="text/vbscript">
Sub Print()
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
OLECMDID_PRINT = 6
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>
<base target="_self" />
</head>
so calling Print() *should* print it automagically, in IE. Also there's an option to print in FireFox without having the print prompt jump up and send to default. Unfortunately Gov is thumbed on IE, a little annoying!
but if you have another option that could be quicker I would love to see it!...
Cheers
maddmike71
Member
73 Points
54 Posts
Re: Printing to a Zebra label printer 105SL
Jun 24, 2011 12:15 AM|LINK
I use this to print simple labels for work and use java to create and call print on a page, I have used it on IE 6,7, and 8 it did not work on 9 and I haven't tried it with other browsers yet, This isn't very pretty but it works, also I had to break up the java function to get it all here so you may need to make the area 1 line again. Here it is.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <table style="width:100%;"> <tr> <td> <asp:Label ID="Label1" runat="server" Text="Destination Name"></asp:Label> </td> <td> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> </td> <td> </td> </tr> <tr> <td> <asp:Label ID="Label2" runat="server" Text="Destination City"></asp:Label> </td> <td> <asp:TextBox ID="txtCity" runat="server"></asp:TextBox> </td> <td> </td> </tr> <tr> <td> <asp:Label ID="Label3" runat="server" Text="PO Number"></asp:Label> </td> <td> <asp:TextBox ID="txtPoNumber" runat="server"></asp:TextBox> </td> <td> </td> </tr> <tr> <td> <asp:Label ID="Label4" runat="server" Text="Quantity"></asp:Label> </td> <td> <asp:TextBox ID="txtQty" runat="server">1</asp:TextBox> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> <input id="Button1" type="button" value="Print" onclick="PrintText()" class="obj_button"/></td> <td> </td> </tr> </table> <script type="text/javascript"> function PrintText() { var p1 = document.getElementById('<%=txtName.ClientID%>').value; var p2 = document.getElementById('<%=txtCity.ClientID%>').value; var p3 = document.getElementById('<%=txtPoNumber.ClientID%>').value; var p4 = document.getElementById('<%=txtQty.ClientID%>').value; var pwin = window.open('', 'printWin', 'width=100,height=300'); pwin.document.open(); pwin.document.write("<font face=\"Lucida Console\"><html><body onload=\"window.print() \">" + String(txt = "^XA<br />\n^MCY<br />\n^XZ<br />\n^XA<br />\n^FWN^CFD,24^PW812 ^LH0,0<br />\n^CI0^PR1^MNY^MTT^MMT^MD0^PON^OMN^LRN<br />\n^XZ<br />\n^XA<br />\n ^MCY<br />\n^XZ<br />\n^XA<br />\n^LRN<br />\n^CF0,70,40^FO70,80<br />\n ^FB700,4,d,C<br />\n^FDCompany Name Here^FS<br />\n^CF0,150,100^FO70,530<br />\n ^FB700,4,d,C<br />\n^FD" + p1 + "\\&" + p2 + "^FS<br />\n^A0,30,20^FO40,30 ^FDShip From:^FS<br />\n^A0,30,20^FO40,410^FDShip To:^FS<br />\n^A0,30,20^FO40,910 ^FDPO Number:^FS<br />\n^FO0,400^GB1000,0,4,^FS<br />\n^FO0,900^GB1000,0,4,^FS<br />\n ^BY4^FO200,900^BC,150,N,N,N^FD" + p3 + "^FS<br />\n^CF0,150,100^FO70,1080<br />\n ^FB700,4,d,C<br />\n^FD" + p3 + "^FS<br />\n^PQ" + p4 + "<br />\n^XZ <br />\n") + "</body></html>"); pwin.document.close(); pwin.window.close(); } </script> </div> </form> </body> </html>beaphy
Member
4 Points
4 Posts
Re: Printing to a Zebra label printer 105SL
Jun 24, 2011 03:52 AM|LINK
Thanks for quick reply maddmike..... I had gone down that road too. A good solution. However, if you have a network printer there's an even better solution, and can be ascy using webservices ...using libraries System.Data, System.Net.Sockets, the bonus is I don't neet to have pop-ups, or render further pages. Works well... Credit to the person I knabbed the idea from, cant' remember where though... but my friday is now a treat!
Thanks again
public void Run_PrintDocket(PART_SERVICE_TRANSACTION _ToPrint) { // Build output string - Example - Printer Settings //strPrintOutput = BuildString1(); // Build output string - Example - Print Label with Barcode and some text (Prints two labels) string strPrintOutput = BuildString2("123456", "2010-01-02", "1234567890", "123", "Harddrive", "D31", "123456", "2"); // Send output to Zebra Printer // 9100 = The default printer port, but that could be changed on the printer // For external access (e.g. through the internet) you need to use the IP/domain name of the router/firewall and also open a port in the firewall and forward the traffic to the internal IP and port set on the printer // Note that for external access appropriate security measures should be added in some way. Connect("10.80.8.65", 9100, strPrintOutput); //(IP, Port,stin } public void Connect(String ip, Int32 port, String strMessage) { try { // Convert String to Byte Array with encoding Windows-1252 //Byte[] data = System.Text.Encoding.ASCII.GetBytes(strMessage); Byte[] data = System.Text.Encoding.GetEncoding(1252).GetBytes(strMessage); // Create connection to printer TcpClient printer = new TcpClient(ip, port); // Get stream object of printer NetworkStream strm = printer.GetStream(); // Write message to stream strm.Write(data, 0, data.Length); // Status Message //Console.WriteLine("Sent: {0}", strMessage); // Close stream strm.Close(); //Close connection to printer printer.Close(); } // end try catch (ArgumentNullException e) { //Console.WriteLine("ArgumentNullException: {0}", e); } catch (SocketException e) { //Console.WriteLine("SocketException: {0}", e); } //Console.WriteLine("\n Press Enter to continue..."); //Console.Read(); } /* * \n = LF (Line Feed) * \r = CR (Carriage Return) * \r\n = CrLf * Printer ignores CR when sent * CR cannot be used in place of LF */ public String BuildString1() { StringBuilder sb = new StringBuilder(); //Clears out printer buffer sb.Append("\n"); //Print the current printer configuration sb.Append("U\n"); return sb.ToString(); } public String BuildString2(String strBarCode, String strDate, String strArticleNumber, String strPurchaseOrderNumber, String strArticleName, String strLocation, String strOrderNumber, String strNoOfLabels) { StringBuilder sb = new StringBuilder(); //Clears out printer buffer sb.Append("\n"); //Clears out the image buffer sb.Append("Heath autoprinting\n"); //Set 8-bit, CodePage Windows 1252 (Latin 1), KDU Sweden (Printer with display) sb.Append("Test\n"); // Create Print Objects return sb.ToString(); }maddmike71
Member
73 Points
54 Posts
Re: Printing to a Zebra label printer 105SL
Jun 24, 2011 06:05 AM|LINK
With our setup this is used on 12 different computers with 12 printers so it turned out to be the best solution here, I just found it odd that nothing would print with IE9.
hf4i
Member
2 Points
1 Post
Re: Printing to a Zebra label printer 105SL
Sep 30, 2011 07:58 PM|LINK
Has anyone come up with a solution for IE9?
I have tried in IE9, Chrome and Firefox with no luck on a local Zebra printer.
I have attempted to 'restore previous version' but with no luck. My operating system shipped with 9.
Any ideas to correct this or to work around it?
Thanks!