2010-11-02 19 views
24

¿Existen impresoras de etiquetas conocidas que aceptarán comandos de impresión desde un sitio web o aplicación web?¿Imprime en una impresora de etiquetas desde un sitio web/aplicación web?

Específicamente, las impresoras de etiquetas de una sola vez, como Dymo, Hermano, cebra, etc.

Alguien ha tenido éxito en la impresión a estas impresoras (sin utilizar un Internet Explorer de sólo cortar o control ActiveX)

Creo que, eventualmente, tendría que haber una solución a medida que avanzamos hacia un mundo más centrado en el navegador.

+0

Esto parece prometedor: [PrinterShare] (http://www.printeranywhere.com/) – drudge

Respuesta

3

Una secuencia de comandos de página web/web compatible con navegador/plataforma no tiene el acceso de bajo nivel necesario para transmitir el comando de idioma de la impresora (como Zebra Printer Language [ZPL]) a la impresora. Para hacer esto, se requiere un control ActiveX/complemento de navegador/applet/bit similar de código ejecutable. Esta limitación no es específica de la impresora, proviene del navegador y no del fabricante de la impresora.

Sin embargo, muchas impresoras de etiquetas le permiten imprimir como si fueran impresoras normales, solo unas que se imprimen en trozos de papel muy pequeños. Puede diseñar su etiqueta usando HTML/CSS. Cuando visualice los resultados, solicite al usuario que vaya a "Archivo> Imprimir" y seleccione su impresora de etiquetas antes de hacer clic en imprimir.

Espero que esto ayude,
Ben

+2

1 Buena idea. Aunque probablemente sea mejor enviar las etiquetas como PDF, de esa manera tendrá un mejor control sobre el formato de salida que utilizando HTML. – sleske

0

Puede imprimir desde un applet de Java firmado, o desde una aplicación Java Web Start:

http://java.sun.com/javase/technologies/desktop/printing/

Eso debería funcionar, si se formatea la salida de impresión por lo se ajusta a las etiquetas.

Tenga en cuenta que la mayoría de los navegadores modernos restringen la compatibilidad con los applets de Java, por lo que puede tener problemas con un applet, dependiendo de los navegadores en uso. En particular, Google Chrome será stop supporting Java applets in September 2015. Estas restricciones hacen no se aplican a Java Web Start, que debería seguir funcionando.

+0

Esta opción pronto será inutilizable ya que varios fabricantes de exploradores restringen y luego eliminan la posibilidad de que los applets de Java se ejecuten https://support.google.com/chrome/answer/1247383?hl=es –

+0

También; https://support.google.com/chrome/answer/6213033 –

+0

@MarkCooper: gracias por la información; Edité mi respuesta. – sleske

9

Las impresoras Dymo tienen un complemento de navegador que le permite imprimir desde javascript. Muy fácil de usar

Revisando esta pregunta algunos años después.

Las impresoras Zebra en red son fáciles de imprimir. En un proyecto, hice que la aplicación web abriera un zócalo a la impresora y le diera instrucciones en ZPL.

+0

Gracias por agregar un enlace a esto, me habría costado encontrarlo sin saber que existía. – Sam

23

Wow. Sé que esto fue preguntado hace más de 4 años, pero después de haber quemado la mayor parte de una semana en busca de un método robusto para imprimir etiquetas desde una aplicación web, tuve que hablar aquí.

Esto es lo que he encontrado:

  • DYMO parece el candidato más probable para la excelencia. Pero no, resulta que solo imprime desde (a) su propia aplicación, o (b) algo usando su SDK. El DYMO SDK utiliza un modelo de dibujo XML que es demasiado complejo y limitado en diseño y estilo. La documentación es dispersa e incomprensible (por ejemplo, ¿cuáles son los valores <Bounds> para los tamaños comunes de etiquetas? ¡No hay ninguna descripción de los parámetros de las etiquetas en ningún lugar!) Tan frustrante, tan decepcionante.

  • Hay qz (was jzebra), que permite la impresión del navegador para dispositivos que hablan EPL, ZPL, FGL, ESC/POS, EPCL y CPCL ... que incluye la serie Zebra. Requiere una carga de integración (ejecutar un servidor web en el dispositivo al que está conectada la impresora de etiquetas), pero funciona.

  • Hay un bien diseñado 3rd party app by Peninsula, que funciona para DYMO (entre otros), pero requiere un paso intermedio de impresión del navegador al PDF. También asumen que nunca escalará lo que desea imprimir con menos del 70%, lo cual es incorrecto.

El PO dice "Me gustaría pensar que, con el tiempo, tendría que ser una solución a medida que avanzamos hacia un mundo más centrada en el navegador." Cuatro años más tarde, iría un paso más allá y sugeriría que cualquier impresora de etiquetas que no pueda imprimir desde un navegador (o simplemente se comporte como una impresora normal con papel pequeño) está cayendo MUCHO por debajo de su potencial. El diseño en HTML + CSS es muy fácil. Los navegadores lo analizan perfectamente y lo procesan con cualquier resolución en cualquier dispositivo de salida. Parece tan obvio

Si alguien sabe de una impresora térmica de etiquetas que imprime desde el navegador en lugar de que el encarcelamiento en las metodologías de integración arcaica, me gustaría mucho saber!

+0

Tenemos un Dymo LabelWriter 450 Twin Turbo al que podemos imprimir desde un navegador. Estamos teniendo problemas para controlar el margen al imprimir html, pero imprime. –

+0

@TimGautier: ¿puede obtener esta impresión desde un navegador en silencio? es decir, sin que aparezca el cuadro de diálogo de impresión? –

+0

No. Creo que necesitarías algún tipo de complemento de navegador para hacer algo como eso. Cualquier otra cosa irá a través del diálogo de impresión del navegador. –

4

También puede intentar buscar PrintNode que proporcionan una solución de impresión en nube y significa que puede imprimir directamente a cualquier impresora en internet.

1

cebra tiene ahora una herramienta llamada 'BrowserPrint' que funciona como PrintNode específicamente para las impresoras Zebra. (a diferencia de Printnode, es gratis para usar con impresoras Zebra)

Algunas impresoras también tienen archivos ppd disponibles y/o pueden configurarse en tazas en un sistema de plataforma Linux o conectarse y comunicarse también vía linux. (lo que significa que no es imposible usar algo de shell scripting, php, perl u otros métodos para imprimirlo creando un daemon de servidor simple o configurando algo como apache o lighttpd en un linux box o incluso un pi de frambuesa conectado al impresora)

+0

Aquí está el enlace: https://www.zebra.com/us/en/products/software/barcode-printers/link-os/browser-print.html – David

0
using System; 
using System.Collections.Generic; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Drawing; 
using System.Drawing.Printing; 
using System.Windows.Forms; 
using System.Runtime.InteropServices; 
using System.IO; 
using System.ComponentModel; 
using System.Data; 
using System.Linq; 
using System.Text; 
using System.Management; 
using System.Reflection; 

public partial class _Default : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 

     GetAllPrinterList(); 
     this.textBox1.Attributes.Add(
    "onkeypress", "button_click(this,'" + this.Button1.ClientID + "')"); 
     this.lstPrinterList.Attributes.Add(
    "onkeypress", "button_click(this,'" + this.Button1.ClientID + "')"); 

    } 

    private void GetAllPrinterList() 
    { 
     //ManagementScope objScope = new ManagementScope(ManagementPath.DefaultPath); //For the local Access 
     //objScope.Connect(); 

     //SelectQuery selectQuery = new SelectQuery(); 
     //selectQuery.QueryString = "Select * from win32_Printer"; 
     //ManagementObjectSearcher MOS = new ManagementObjectSearcher(objScope, selectQuery); 
     //ManagementObjectCollection MOC = MOS.Get(); 
     //foreach (ManagementObject mo in MOC) 
     //{ 
     // lstPrinterList.Items.Add(mo["Name"].ToString()); 
     // //lstPrinterList.Items.Add(new ListItem(mo["Name"].ToString())); 

     //} 

     lstPrinterList.Items.Add("\\\\10.32.65.6\\Parcel-Zebra-FDX ZM400"); 
     lstPrinterList.Items.Add("\\\\10.32.65.4\\Singles_Station_Z_Printer"); 
     lstPrinterList.Items.Add("\\\\10.32.65.12\\ZebraZ4M-Packaging"); 
     if (lstPrinterList.Items.Count > 3) 
     { 
     lstPrinterList.Items.RemoveAt(5); 
     lstPrinterList.Items.RemoveAt(4); 
     lstPrinterList.Items.RemoveAt(3); 

     } 

     //LocalPrintServer printServer = new LocalPrintServer(); 
     //string printer; 
     //printer = LocalPrintServer.DefaultPrintQueue; 
     //System.Management.ObjectQuery oquery = 
     //  new System.Management.ObjectQuery("SELECT * FROM Win32_Printer"); 

     // System.Management.ManagementObjectSearcher mosearcher = 
     //  new System.Management.ManagementObjectSearcher(oquery); 

     // System.Management.ManagementObjectCollection moc = mosearcher.Get(); 

     // foreach (ManagementObject mo in moc) 
     // { 
     //  System.Management.PropertyDataCollection pdc = mo.Properties; 
     //  foreach (System.Management.PropertyData pd in pdc) 
     //  { 
     //   // if ((bool)mo["Network"]) 
     //   // { 
     //    lstPrinterList.Items.Add(mo["Name"].ToString()); 
     //   // } 
     //  } 
     // } 

     //} 
     //  using (var printServer = new PrintServer(string.Format(@"\\{0}", PrinterServerName))) 
     //{ 
     // foreach (var queue in printServer.GetPrintQueues()) 
     // { 
     //  if (!queue.IsShared) 
     //  { 
     //   continue; 
     //  } 
     //  Debug.WriteLine(queue.Name); 
     //  } 
     // } 
     //foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters) 
     //{ 
     //MessageBox.Show(printer); 
     //System.Web.UI.WebControls.ListBox lstPrinterList = new System.Web.UI.WebControls.ListBox(); 
     //System.Web.UI.WebControls.ListBox lstPrinterList = (System.Web.UI.WebControls.ListBox)Page.FindControl("lstPrinterList"); 
     //lstPrinterList.Text = "Zebra 110PAX4 (203 ;dpi)"; 

     //lstPrinterList.Items.Add(printer.ToString()); 
     //lstPrinterList.Items.Add(new ListItem(printer)); 
     //lstPrinterList.Items.Add(printer); 
     //System.Web.UI.WebControls.ListBox lstPrinterList = (System.Web.UI.WebControls.ListBox)Page.FindControl("ListBox1"); 
     //Zebra 110PAX4 (203 dpi) 
     //lstPrinterList.Items.Insert(printer); 
     //} 
    } 


    //private void lstPrinterList_OnClick(object sender, System.EventArgs e) 
    //{ 
    // // Get the currently selected item in the ListBox. 
    // string curItem = lstPrinterList.SelectedItem.ToString(); 

    // // Find the string in ListBox2. 
    // int index = lstPrinterList.DataTextField(curItem); 
    // //int index = lstPrinterList.FindString(curItem); 
    // //lstPrinterList.DataTextField(curItem); 
    // // If the item was not found in ListBox 2 display a message box, otherwise select it in ListBox2. 
    // if (index == -1) 
    //  MessageBox.Show("Item is not available in ListBox2"); 
    // else 
    //  lstPrinterList.SetSelected(index, true); 
    //} 

    //private void button1_Click(object sender, System.EventArgs e) 
    //{ 

    // string str = File.ReadAllText("lpn.prn"); 
    // str = str.Replace("BOX_TYPE", "boom"); 
    // str = str.Replace("11111111", textBox1.Text); 
    // File.WriteAllText("lpn.prn", str); 
    //   // Print the file to the printer. 
    // RawPrinterHelper.SendFileToPrinter("\\\\Zebra-FDX ZM400 200 dpi (ZPL)", "C:\\Users\\Administrator\\Documents\\Visual Studio 2015\\Projects\\WindowsFormsApplication4\\Prn Print\\bin\\Debug\\lpn.prn"); 
    //} 

    public void button1_Click(object sender, System.EventArgs e) 
    { 
     String prnFile = "lpn2.prn"; 
     string s = File.ReadAllText(prnFile); 
     string printer; 
     String Printer = lstPrinterList.SelectedItem.ToString(); 
     s = s.Replace("*description*", "snuffles"); 
     s = s.Replace("*barcode*", textBox1.Text); 
     //File.WriteAllText("PPlpn.prn", s); 
     //s = "^XA^LH30,30\n^FO20,10^ADN,90,50^AD^FDHello World^FS\n^XZ"; 
     printer = lstPrinterList.SelectedItem.Value; 
     PrintDialog pd = new PrintDialog(); 
     pd.PrinterSettings = new PrinterSettings(); 
     RawPrinterHelper.SendStringToPrinter(printer, s); 
     //RawPrinterHelper.SendStringToPrinter(Printer, s); 
     //Response.Redirect(Request.RawUrl.Replace(Request.Url.Query, "?__VIEWSTATE=%2%3D&ctl00%24MainContent%24textBox1=bp300&ctl00%24MainContent%24lstPrinterList=Shipping+Printer")); 




    } 
    protected void textBox1_TextChanged(object sender, EventArgs e) 
    { 

    } 
} 




public class RawPrinterHelper 
{ 
    // Structure and API declarions: 
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] 
    public class DOCINFOA 
    { 
     [MarshalAs(UnmanagedType.LPStr)] 
     public string pDocName; 
     [MarshalAs(UnmanagedType.LPStr)] 
     public string pOutputFile; 
     [MarshalAs(UnmanagedType.LPStr)] 
     public string pDataType; 
    } 
    [DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
    public static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd); 

    [DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
    public static extern bool ClosePrinter(IntPtr hPrinter); 

    [DllImport("winspool.Drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
    public static extern bool StartDocPrinter(IntPtr hPrinter, Int32 level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di); 

    [DllImport("winspool.Drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
    public static extern bool EndDocPrinter(IntPtr hPrinter); 

    [DllImport("winspool.Drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
    public static extern bool StartPagePrinter(IntPtr hPrinter); 

    [DllImport("winspool.Drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
    public static extern bool EndPagePrinter(IntPtr hPrinter); 

    [DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
    public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten); 

    // SendBytesToPrinter() 
    // When the function is given a printer name and an unmanaged array 
    // of bytes, the function sends those bytes to the print queue. 
    // Returns true on success, false on failure. 
    public static bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, Int32 dwCount) 
    { 
     Int32 dwError = 0, dwWritten = 0; 
     IntPtr hPrinter = new IntPtr(0); 
     DOCINFOA di = new DOCINFOA(); 
     bool bSuccess = false; // Assume failure unless you specifically succeed. 
     di.pDocName = "My C#.NET RAW Document"; 
     di.pDataType = "RAW"; 

     // Open the printer. 
     if (OpenPrinter(szPrinterName.Normalize(), out hPrinter, IntPtr.Zero)) 
     { 
      // Start a document. 
      if (StartDocPrinter(hPrinter, 1, di)) 
      { 
       // Start a page. 
       if (StartPagePrinter(hPrinter)) 
       { 
        // Write your bytes. 
        bSuccess = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten); 
        EndPagePrinter(hPrinter); 
       } 
       EndDocPrinter(hPrinter); 
      } 
      ClosePrinter(hPrinter); 
     } 
     // If you did not succeed, GetLastError may give more information 
     // about why not. 
     if (bSuccess == false) 
     { 
      dwError = Marshal.GetLastWin32Error(); 
     } 
     return bSuccess; 
    } 

    public static bool SendFileToPrinter(string szPrinterName, string szFileName) 
    { 
     // Open the file. 
     FileStream fs = new FileStream(szFileName, FileMode.Open); 
     // Create a BinaryReader on the file. 
     BinaryReader br = new BinaryReader(fs); 
     // Dim an array of bytes big enough to hold the file's contents. 
     Byte[] bytes = new Byte[fs.Length]; 
     bool bSuccess = false; 
     // Your unmanaged pointer. 
     IntPtr pUnmanagedBytes = new IntPtr(0); 
     int nLength; 

     nLength = Convert.ToInt32(fs.Length); 
     // Read the contents of the file into the array. 
     bytes = br.ReadBytes(nLength); 
     // Allocate some unmanaged memory for those bytes. 
     pUnmanagedBytes = Marshal.AllocCoTaskMem(nLength); 
     // Copy the managed byte array into the unmanaged array. 
     Marshal.Copy(bytes, 0, pUnmanagedBytes, nLength); 
     // Send the unmanaged bytes to the printer. 
     bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, nLength); 
     // Free the unmanaged memory that you allocated earlier. 
     Marshal.FreeCoTaskMem(pUnmanagedBytes); 
     return bSuccess; 
    } 

    public static bool SendStringToPrinter(string szPrinterName, string szString) 
    { 
     IntPtr pBytes; 
     Int32 dwCount; 
     // How many characters are in the string? 
     dwCount = szString.Length; 
     // Assume that the printer is expecting ANSI text, and then convert 
     // the string to ANSI text. 
     pBytes = Marshal.StringToCoTaskMemAnsi(szString); 
     // Send the converted ANSI string to the printer. 
     SendBytesToPrinter(szPrinterName, pBytes, dwCount); 
     Marshal.FreeCoTaskMem(pBytes); 
     return true; 
    } 
} 

Esto es lo que creé en C# y funcionó muy bien. Esta es una aplicación web.

Cuestiones relacionadas