Question

Je suis en train d'imprimer la page de code étendu 850 caractères à l'aide ZPL II à un zèbre S4M. Chaque fois que l'un des caractères étendus à savoir valeur ASCII> 127 est utilisé, je reçois une boîte de différentes nuances de gris au lieu de la valeur réelle.

Je suis en train d'imprimer ± et ° (ALT + 0177 et ALT + 0176). Je soupçonne que c'est le RawPrinterHelper que je suis en train d'utiliser (comme téléchargé à partir de MS, et un autre de CodeProject) mais je ne vois pas où les codes de caractère vont mal.

Bizarrement, l'impression directe à partir de Bloc-notes rend les caractères corrects, ce qui me porte à croire qu'il ya un problème avec la classe d'aide de l'imprimante brute.

Je ne suis pas lié à l'utilisation de la classe Printer Raw Helper donc s'il y a une meilleure façon de le faire, je suis plus heureux de les voir.

EXEMPLE ZPLII Sans caractères échappées

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

Avec échappé les caractères (essayé les deux majuscules et minuscules)

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

Aide Printer Raw

[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);
    }
}

Correction réelle de la réponse acceptée jeu de caractères Internationalisation (code ^ CI27 ) à la page de code 1252.

^XA
^FO30,200^AD^CI27^FH,18,10^FD35 _b0 2 _b1 ^FS
^FS
^XZ
Était-ce utile?

La solution

Oui, les cases grisées ont ces codes d'octets, dans la page de code 1252. Ce qui est sans doute la page de code par défaut de l'imprimante, 1252 est la page de code Windows pour l'Europe occidentale et dans les Amériques.

Vous devrez envoyer une commande pour changer la page de code à 850. A en juger par

scroll top