2010-04-21 62 views
3

我試圖使用ZPL II打印擴展代碼頁850個字符到Zebra S4M。每當其中一個擴展字符I.E.使用ASCII值> 127我得到一盒不同的灰色陰影,而不是實際值。ZPL II擴展字符

我在打印±和°(ALT + 0177和ALT + 0176)。我懷疑它正在嘗試使用的RawPrinterHelper(從MS下載,另一個來自CodeProject),但是我無法看到字符代碼出錯的地方。

奇怪的是,從記事本直接打印呈現正確的字符,這導致我相信它是原始打印機助手類的問題。

我並不打算使用Raw Printer Helper類,所以如果有更好的方法,我很樂意看到它們。

樣品ZPLII 沒有逃脫字符

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

隨着轉義字符(嘗試都大寫和小寫)

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

原始打印機助手

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

從接受的答案實際修復的字符集國際(代碼^CI27)到代碼頁1252

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

回答

5

是的,陰影框有那些字節代碼,在代碼頁1252哪些無疑是打印機的默認代碼頁,1252是西歐和美洲的Windows代碼頁。

你必須發送一個命令代碼頁轉換到850從the manual來看,需要^ CI選擇字符集13

在1252保持的代碼頁和改變你的字符代碼將是明智的。字形表位於手冊的後面。

+0

感謝漢斯 - 我會在早上去一趟,看看能否解決問題 – Mauro 2010-04-21 18:05:15