Pregunta

Estoy tratando de imprimir la página de códigos extendida 850 caracteres usando ZPL II a un S4M de Zebra. Siempre que uno de los caracteres extendidos es decir, valor ASCII> 127 se utiliza consigo una caja de distintos tonos de gris en lugar del valor real.

Estoy intentando imprimir y ± ° (ALT + 0177 + 0176 y ALT). Sospecho su RawPrinterHelper la que estoy tratando de uso (como descargado de la EM, y otro de CodeProject) sin embargo no puedo ver donde los códigos de caracteres van mal.

Extrañamente, la impresión directa desde el Bloc de notas hace que los caracteres correctos, lo que me lleva a creer que es un problema con la clase de ayuda crudo de impresión.

No estoy ligado a la utilización de la clase de impresora Raw ayudante así que si hay una mejor manera de hacerlo, estoy más que feliz de verlos.

MUESTRA ZPLII Sin caracteres escapados

^XA
^FO30,200^AD^FH,18,10^FD35 ± 2 ° ^FS
^FS
^XZ

Con escapó caracteres (intentado tanto mayúsculas y minúsculas)

^XA
^FO30,200^AD^FH,18,10^FD35 _b0 2 _b1 ^FS
^FS
^XZ

Raw impresora ayudante

[StructLayout(LayoutKind.Sequential)]
public struct DOCINFO
{
    [MarshalAs(UnmanagedType.LPWStr)]
    public string printerDocumentName;
    [MarshalAs(UnmanagedType.LPWStr)]
    public string pOutputFile;
    [MarshalAs(UnmanagedType.LPWStr)]
    public string printerDocumentDataType;
}

public class RawPrinter
{
    [
        DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = false,
            CallingConvention = CallingConvention.StdCall)]
    public static extern long OpenPrinter(string pPrinterName, ref IntPtr phPrinter, int pDefault);

    [
        DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = false,
            CallingConvention = CallingConvention.StdCall)]
    public static extern long StartDocPrinter(IntPtr hPrinter, int Level, ref DOCINFO pDocInfo);

    [
        DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true,
            CallingConvention = CallingConvention.StdCall)]
    public static extern long StartPagePrinter(IntPtr hPrinter);

    [
        DllImport("winspool.drv", CharSet = CharSet.Ansi, ExactSpelling = true,
            CallingConvention = CallingConvention.StdCall)]
    public static extern long WritePrinter(IntPtr hPrinter, string data, int buf, ref int pcWritten);

    [
        DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true,
            CallingConvention = CallingConvention.StdCall)]
    public static extern long EndPagePrinter(IntPtr hPrinter);

    [
        DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true,
            CallingConvention = CallingConvention.StdCall)]
    public static extern long EndDocPrinter(IntPtr hPrinter);

    [
        DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true,
            CallingConvention = CallingConvention.StdCall)]
    public static extern long ClosePrinter(IntPtr hPrinter);

    public static void SendToPrinter(string printerJobName, string rawStringToSendToThePrinter,
                                     string printerNameAsDescribedByPrintManager)
    {
        IntPtr handleForTheOpenPrinter = new IntPtr();
        DOCINFO documentInformation = new DOCINFO();
        int printerBytesWritten = 0;
        documentInformation.printerDocumentName = printerJobName;
        documentInformation.printerDocumentDataType = "RAW";
        OpenPrinter(printerNameAsDescribedByPrintManager, ref handleForTheOpenPrinter, 0);
        StartDocPrinter(handleForTheOpenPrinter, 1, ref documentInformation);
        StartPagePrinter(handleForTheOpenPrinter);
        WritePrinter(handleForTheOpenPrinter, rawStringToSendToThePrinter, rawStringToSendToThePrinter.Length,
                     ref printerBytesWritten);
        EndPagePrinter(handleForTheOpenPrinter);
        EndDocPrinter(handleForTheOpenPrinter);
        ClosePrinter(handleForTheOpenPrinter);
    }
}

Fix real de la respuesta aceptada establecer el carácter de internacionalización (Código ^ CI27 ) para página de códigos 1252.

^XA
^FO30,200^AD^CI27^FH,18,10^FD35 _b0 2 _b1 ^FS
^FS
^XZ
¿Fue útil?

Solución

Sí, las casillas sombreadas tienen esos códigos de bytes, en la página de códigos 1252. Lo que sin duda es la página de códigos predeterminada para la impresora, 1252 es la página de códigos de Windows para Europa occidental y América.

Se tendrá que enviar un comando para cambiar la página de códigos a 850. A juzgar por la manual, que requiere ^ CI para seleccionar el conjunto de caracteres 13.

Mantener la página de códigos en 1252 y cambiar sus códigos de caracteres en vez sería prudente. Las tablas de glifos están en la parte posterior del manual.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top