我正在尝试使用ZPL II将扩展代码页850字符打印到Zebra S4M。每当一个扩展字符I.E.
我正在尝试打印±和°(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
答案 0 :(得分:5)
是的,阴影框中包含那些字节代码,代码页1252.毫无疑问,这是打印机的默认代码页,1252是西欧和美洲的Windows代码页。
您必须发送命令将代码页切换为850.从the manual判断,这需要^ CI来选择字符集13.
保持代码页为1252并改变你的字符代码是明智的。字形表位于手册的后面。