- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 2 台 Zebra GC420t 打印机和一个创建 ZPL 代码并将其发送到选定打印机的 wpf 应用程序。打印的标签差异太大。请参见下图。
The outcomes and printer configurations
打印的 ZPL 代码为:(标签为 10x8.1 cm)
^XA
^PON
^CI27
^MMT
^PW800
^LL648
^FX Pictogram0
^FO632,104
^GFA,1300,1300,13,,W0G1GCM0W0G3G4M0,::::::::::::::::::::::::S0G7GCQ0P0HFG1HFGEP0K0G4H0G3IFGBJFG8G0G3L0K0G7G0G7JFGBG8G1IFGCG7L0K0G3JFG0G1GFG8H0IFGEL0K0G3HFGCH0G1GFG8I0G3GFGEL0K0G3GFJ0G7GBHFG8I0GEL0K0G3G8G0G3IFG9KFG0GEL0K0G3LFG0G7KFGEL0K0G3KFG8H0G7JFGEL0K0G1IFGEK0G1IFGCL0K0G1HFG8N0G7GFGCL0K0G1GEQ0G1GEG0G3G8I0K0G3GCO0G6G0G1GEH7G8I0K0G3GCO0H7G1GEH7J0K0G3GCO0G7GFG1GEG7G6J0K0G3GCO0G3GEG1GEGFG6J0K0G3GCO0G3GFG8GCGFGEJ0K0G1G8O0G3GFG9GCGDGEJ0I0G2G0G3G8G1G8M0G3GFG9GEGFG8J0I0G7G0G3G9GBGCN0GFG9HFG8J0I0G7GBG3G9GFG8N0GFGDHFG8J0I0G3GFG7GDGFO0GFGDGFGBK0I0G3GFG7GDGFO0G7G9GEG2K0I0G3GEG7HFO0G3G1GCL0I0G3JFN0G3GFG8G3L0I0G1GFGBGFGEN0G3IFGCK0J0GFG8G3GCN0KFG8J0J0GFG8GFGCM0G7LFG8I0J0G7GCGFG8M0G7JFG3GFG8I0G3JFGCG7JFI0G1HFGEG7H0G1G8I0G3JFG8G1JFI0G3HFGEG7G8L0G3PFI0G7HFGEG3GFL0G3PFI0G7HFGEG1GFL0G3PFI0G3HFGEG0GFL0G3PFI0G1HFGEN0G3PFJ0G7HFG8H0G3G8I0G3PFJ0G7HFGCG0G1GFG8I0G3PFJ0G1HFG8G1HFG8I0V0KFGCJ0V0G7IFGEK0X0G7G8L0,:::::::::::::::::::::::::::::
^FS
^FX Pictogram1
^FO632,280
^GFA,1300,1300,13,,:::::::::::::::Q0GFGES0P0G7HFGCR0P0IFGER0O0G3JFG8Q0O0G7JFGCQ0::O0KFGEQ0:O0G7JFGCQ0:::::O0G3JFG8Q0::::::O0G1JFR0::::::P0IFGER0:::::P0G7HFGCR0::::::P0G3HFG8R0::P0G1HFS0Q0GFGES0Q0G3G8S0,::Q0G7GCS0P0G1HFS0P0G3HFG8R0P0G7HFGCR0P0IFGER0:O0G1JFR0::::::P0IFGER0P0G7HFGCR0:P0G1HFS0Q0GFGES0,::::::::::::::
^FS
^FX Pictogram2
^FO632,456
^FS
^FX ItemNumber
^CF0,30
^FO25,27,0
^FB608,1,,L,
^FH
^FD
10001A
^FS
^FX ItemName
^CF0,50
^FO25,55,0
^FB608,1,,L,
^FH
^FD
_52_55_43_4F_47_45_4E_20_44_46_4C_20_33_30_30
^FS
^FX BatchNumber
^CF0,50
^FO25,105,0
^FB608,1,,L,
^FH
^FD
17-0001
^FS
^FX Amount
^CF0,30
^FO25,150,0
^FB608,1,,L,
^FH
^FD
120 Kg
^FS
^FX LabelDate
^CF0,30
^FO25,185,0
^FB608,1,,L,
^FH
^FD
29.05.2017
^FS
^FX Barcode
^FO25,230,0
^BY3,2,75
^BCN
^FD
869316388539
^FS
^FX Warnings
^CF0,20
^FO25,350,0
^FB560,30,,,L,
^FH
^FD
_48_33_30_32_3A_20_59_75_74_75_6C_6D_61_73_69_20_68_61_6C_69_6E_64_65_20_7A_61_72_61_72_6C_69_64_69_72_2E_5C_26_48_33_31_38_3A_20_43_69_64_64_69_20_67_F6_7A_20_68_61_73_61_72_69_6E_61_20_79_6F_6C_20_61_E7_61_72_2E_5C_26_50_32_36_34_3A_20_45_6C_6C_65_E7_6C_65_6D_65_64_65_6E_20_73_6F_6E_72_61_20_85_20_69_6C_65_20_69_79_69_63_65_20_79_69_6B_61_79_69_6E_2E_5C_26_50_32_38_30_3A_20_4B_6F_72_75_79_75_63_75_20_65_6C_64_69_76_65_6E_2F_6B_6F_72_75_79_75_63_75_20_6B_69_79_61_66_65_74_2F_67_F6_7A_20_6B_6F_72_75_79_75_63_75_2F_79_FC_7A_20_6B_6F_72_75_79_75_63_75_20_6B_75_6C_6C_61_6E_69_6E_2E_A0_5C_26_50_33_31_30_3A_20_48_65_6D_65_6E_A0_55_4C_55_53_41_4C_20_5A_45_48_49_52_20_44_41_4E_49_53_4D_41_20_4D_45_52_4B_45_5A_49_4E_49_4E_20_31_31_34_20_4E_4F_4C_55_20_54_45_4C_45_46_4F_4E_55_4E_55_A0_76_65_79_61_20_64_6F_6B_74_6F_72_75_2F_68_65_6B_69_6D_69_20_61_72_61_79_69_6E_2E_A0_5C_26_50_33_30_31_2B_50_33_31_32_3A_20_59_55_54_55_4C_44_55_47_55_4E_44_41_3A_20_4B_65_6E_64_69_6E_69_7A_69_20_69_79_69_20_68_69_73_73_65_74_6D_69_79_6F_72_73_61_6E_69_7A_A0_55_4C_55_53_41_4C_20_5A_45_48_49_52_20_44_41_4E_49_53_4D_41_20_4D_45_52_4B_45_5A_49_4E_49_4E_20_31_31_34_20_4E_4F_4C_55_20_54_45_4C_45_46_4F_4E_55_4E_55_A0_76_65_79_61_20_64_6F_6B_74_6F_72_75_2F_68_65_6B_69_6D_69_20_61_72_61_79_69_6E_2E_5C_26_50_33_30_35_2B_50_33_35_31_2B_50_33_33_38_3A_20_47_D6_5A_20_49_4C_45_20_54_45_4D_41_53_49_20_48_41_4C_49_4E_44_45_3A_20_53_75_20_69_6C_65_20_62_69_72_6B_61_E7_20_64_61_6B_69_6B_61_20_64_69_6B_6B_61_74_6C_69_63_65_20_64_75_72_75_6C_61_79_69_6E_2E_20_54_61_6B_69_6C_69_20_76_65_20_79_61_70_6D_61_73_69_20_6B_6F_6C_61_79_73_61_2C_20_6B_6F_6E_74_61_6B_20_6C_65_6E_73_6C_65_72_69_20_E7_69_6B_61_72_74_69_6E_2E_20_44_75_72_75_6C_61_6D_61_79_61_20_64_65_76_61_6D_20_65_64_69_6E_2E_5C_26_50_35_30_31_3A_20_49_E7_65_72_69_67_69_2F_6B_61_62_69_20_85_20_62_65_72_74_61_72_61_66_20_65_64_69_6E_2E
^FS
^FX FormNumber
^CF0,30
^FO600,630,0
^FB160,1,,C,
^FH
^FDF 540.006.2^FS
^XZ
您可以在 labelary.com/viewer.html 中查看 zpl 代码
我正在使用 RawPrinterHelper 将 ZPL 字符串发送到打印机。
有人能帮帮我吗?
对于任何像我这样绞尽脑汁使用 ZPL 语言打印图像的可怜人,这里是我所做的。
int x = 300, y = 300;
pictogram0 = ZplImageConverter.GetZpl(ZplTools.ResizeImageData(ZplTools.RotateImageData(pictogramList[0]), x, y));
public class ZplImageConverter
{
public const int MaxBlacklimit = 765;
private static Dictionary<int, String> CompressMap
{
get
{
if (_CompressMap == null)
{
_CompressMap = new Dictionary<int, string>();
_CompressMap.Add(1, "G");
_CompressMap.Add(2, "H");
_CompressMap.Add(3, "I");
_CompressMap.Add(4, "J");
_CompressMap.Add(5, "K");
_CompressMap.Add(6, "L");
_CompressMap.Add(7, "M");
_CompressMap.Add(8, "N");
_CompressMap.Add(9, "O");
_CompressMap.Add(10, "P");
_CompressMap.Add(11, "Q");
_CompressMap.Add(12, "R");
_CompressMap.Add(13, "S");
_CompressMap.Add(14, "T");
_CompressMap.Add(15, "U");
_CompressMap.Add(16, "V");
_CompressMap.Add(17, "W");
_CompressMap.Add(18, "X");
_CompressMap.Add(19, "Y");
_CompressMap.Add(20, "g");
_CompressMap.Add(40, "h");
_CompressMap.Add(60, "i");
_CompressMap.Add(80, "j");
_CompressMap.Add(100, "k");
_CompressMap.Add(120, "l");
_CompressMap.Add(140, "m");
_CompressMap.Add(160, "n");
_CompressMap.Add(180, "o");
_CompressMap.Add(200, "p");
_CompressMap.Add(220, "q");
_CompressMap.Add(240, "r");
_CompressMap.Add(260, "s");
_CompressMap.Add(280, "t");
_CompressMap.Add(300, "u");
_CompressMap.Add(320, "v");
_CompressMap.Add(340, "w");
_CompressMap.Add(360, "x");
_CompressMap.Add(380, "y");
_CompressMap.Add(400, "z");
}
return _CompressMap;
}
}
private static Dictionary<int, String> _CompressMap;
public static string GetZpl(byte[] imageData, bool useCompression = true)
{
var imgConverter = new ImageConverter();
var bmp = (Bitmap)imgConverter.ConvertFrom(imageData);
var bytesPerRow = bmp.Width / 8;
if (bmp.Width % 8 > 0)
bytesPerRow = (((int)(bmp.Width / 8)) + 1);
else
bytesPerRow = bmp.Width / 8;
var totalBytes = bytesPerRow * bmp.Height;
string hex = CreateMonochromeHex(bmp, bytesPerRow, totalBytes);
return string.Format("^GFA,{0},{0},{1},{2}", totalBytes, bytesPerRow, useCompression ? EncodeHexAscii(hex, bytesPerRow) : hex);
}
#region Helpers
private static string CreateMonochromeHex(Bitmap bmp, int bytesPerRow, int totalBytes)
{
var sb = new StringBuilder();
var graphics = Graphics.FromImage(bmp);
graphics.DrawImage(bmp, 0, 0);
var auxBinaryChar = new char[] { '0', '0', '0', '0', '0', '0', '0', '0' };
int index = 0;
for (int h = 0; h < bmp.Height; h++)
{
for (int w = 0; w < bmp.Width; w++)
{
//Remove borders
if (h == 0 || w == bmp.Width - 1 || w == 0 || h == bmp.Height - 1)
{
auxBinaryChar[index] = '0';
index++;
}
else
{
var rgb = bmp.GetPixel(w, h);
char auxChar = '1';
/* Determine using Luma
* Source1 = http://web.archive.org/web/20141017085834/http://nicholas.piasecki.name:80/blog/2013/02/using-the-epl2-gw-command/
* Source2 = http://web.archive.org/web/20141025194839/https://en.wikipedia.org/wiki/Luma_(video)
*
* var threshold = 127;
* var color = bitmap.GetPixelx, y;
* var luminance = color.R * 0.3 + color.G * 0.59 + color.B * 0.11;
* dotsindex = luminance < threshold;
*
*/
//If color is not pure white then apply thermal heat to draw black otherwise do not apply thermal heat to draw nothing (white)
if ((rgb.R + rgb.G + rgb.B) >= ZplImageConverter.MaxBlacklimit)
auxChar = '0';
auxBinaryChar[index] = auxChar;
index++;
}
if (index == 8 || w == (bmp.Width - 1))
{
sb.Append(FourByteBinary(new String(auxBinaryChar)));
auxBinaryChar = new char[] { '0', '0', '0', '0', '0', '0', '0', '0' };
index = 0;
}
}
sb.Append("\n");
}
return sb.ToString();
}
private static string FourByteBinary(string binaryStr)
{
return string.Format("{0:X2}", Convert.ToByte(binaryStr, 2));
}
private static string EncodeHexAscii(string hex, int bytesPerRow)
{
int maxlinea = bytesPerRow * 2;
var sbCode = new StringBuilder();
var sbLinea = new StringBuilder();
String previousLine = null;
int counter = 1;
char aux = hex[0];
bool firstChar = false;
for (int i = 1; i < hex.Length; i++)
{
if (firstChar)
{
aux = hex[i];
firstChar = false;
continue;
}
if (hex[i] == '\n')
{
if (counter >= maxlinea && aux == '0')
{
sbLinea.Append(",");
}
else if (counter >= maxlinea && aux == 'F')
{
sbLinea.Append("!");
}
else if (counter > 20)
{
int multi20 = (counter / 20) * 20;
int resto20 = (counter % 20);
sbLinea.Append(CompressMap[multi20]);
if (resto20 != 0)
{
sbLinea.Append(CompressMap[resto20] + aux);
}
else
{
sbLinea.Append(aux);
}
}
else
{
sbLinea.Append(CompressMap[counter] + aux);
}
counter = 1;
firstChar = true;
if (sbLinea.ToString().Equals(previousLine))
{
sbCode.Append(":");
}
else
{
sbCode.Append(sbLinea.ToString());
}
previousLine = sbLinea.ToString();
sbLinea.Length = 0;
continue;
}
if (aux == hex[i])
{
counter++;
}
else
{
if (counter > 20)
{
int multi20 = (counter / 20) * 20;
int resto20 = (counter % 20);
sbLinea.Append(CompressMap[multi20]);
if (resto20 != 0)
{
sbLinea.Append(CompressMap[resto20] + aux);
}
else
{
sbLinea.Append(aux);
}
}
else
{
sbLinea.Append(CompressMap[counter] + aux);
}
counter = 1;
aux = hex[i];
}
}
return sbCode.ToString();
}
#endregion
}
public static class ZplTools
{
public static string Normalize(string input)
{
if (string.IsNullOrEmpty(input))
return null;
var sb = new StringBuilder();
for (int i = 0; i < input.Length; i++)
{
var byteArray = Encoding.GetEncoding(1252).GetBytes(input.Substring(i, 1));
var hexString = BitConverter.ToString(byteArray);
sb.Append("_" + hexString.Replace("-", "_"));
}
return sb.ToString();
}
public static byte[] ConvertToMonochromeBitmap(byte[] imageData)
{
var converter = new System.Drawing.ImageConverter();
var image = (System.Drawing.Bitmap)converter.ConvertFrom(imageData);
return (byte[])converter.ConvertTo(image.ConvertToMonochromeTiff(), typeof(byte[]));
}
public static byte[] ResizeImageData(byte[] imageData, int with, int height)
{
var converter = new System.Drawing.ImageConverter();
using (var source = (System.Drawing.Image)converter.ConvertFrom(imageData))
{
using (var thumbnail = new System.Drawing.Bitmap(with, height))
{
using (var g = System.Drawing.Graphics.FromImage(thumbnail))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(source, 0, 0, with, height);
}
return (byte[])converter.ConvertTo(thumbnail, typeof(byte[]));
}
}
}
public static byte[] RotateImageData(byte[] imageData)
{
System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter();
using (var image = (System.Drawing.Image)converter.ConvertFrom(imageData))
{
image.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipXY);
return (byte[])converter.ConvertTo(image, typeof(byte[]));
}
}
public static string GetImageZplUploadString(byte[] imageData, string imageName)
{
return string.Format("^XA~DYE:{2},P,P,{0},,{1}^XZ", imageData.Length, ZplTools.GetASCIHexString(imageData), imageName);
}
public static string GetASCIHexString(byte[] data)
{
StringBuilder hex = new StringBuilder();
foreach (byte b in data)
hex.AppendFormat("{0:X2}", b);
return hex.ToString();
}
}
最佳答案
我不知道为什么,但在 ZPL 的顶部添加一个 ^FWN 命令解决了问题。
关于c# - 两台 GC420t 打印机不同的 ZPL 结果(ZPL,C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44236657/
我对这个错误很困惑: Cannot implicitly convert type 'System.Func [c:\Program Files (x86)\Reference Assemblies\
考虑这段代码: pub trait Hello { fn hello(&self); } impl Hello for Any { fn hello(&self) {
问题很简单。是否可以构造这样一个类型 T,对于它下面的两个变量声明会产生不同的结果? T t1 = {}; T t2{}; 我已经研究 cppreference 和标准一个多小时了,我了解以下内容:
Intellij idea 给我这个错误:“Compare (T, T) in Comparator cannot be applied to (T, T)” 对于以下代码: public class
任何人都可以告诉我 : n\t\t\t\t\n\t\t\t 在以下来自和 dwr 服务的响应中的含义和用途是什么. \r\n\t\t\t \r\n\t\t\t
让 T 成为一个 C++ 类。 下面三个指令在行为上有什么区别吗? T a; T a(); T a = T(); T 为不带参数的构造函数提供了显式定义这一事实是否对问题有任何改变? 后续问题:如果
Rust中的智能指针是什么 智能指针(smart pointers)是一类数据结构,是拥有数据所有权和额外功能的指针。是指针的进一步发展 指针(pointer)是一个包含内存地
比如我有一个 vector vector > v={{true,1},{true,2},{false,3},{false,4},{false,5},{true,6},{false,7},{true,8
我有一个来自 .xls 电子表格的数据框,我打印了 print(df.columns.values) 列,输出包含一个名为:Poll Responses\n\t\t\t\t\t。 我查看了 Excel
This question already has answers here: What are good reasons for choosing invariance in an API like
指针类型作为类型前缀与在类型前加斜杠作为后缀有什么区别。斜线到底是什么意思? 最佳答案 语法 T/~ 和 T/& 基本上已被弃用(我什至不确定编译器是否仍然接受它)。在向新向量方案过渡的初始阶段,[T
我正在尝试找到一种方法来获取模板参数的基类。 考虑以下类: template class Foo { public: Foo(){}; ~Foo(){};
这是一个让我感到困惑的小问题。我不知道如何描述它,所以只看下面的代码: struct B { B() {} B(B&) { std::cout ::value #include
为什么有 T::T(T&) 而 T::T(const T&) 更适合 copy ? (大概是用来实现move语义的???) 原始描述(被melpomene证明是错误的): 在C++11中,支持了一种新
在 Java 7 中使用 eclipse 4.2 并尝试实现 List 接口(interface)的以下方法时,我收到了警告。 public T[] toArray(T[] a) { ret
假设有三个函数: def foo[T](a:T, b:T): T = a def test1 = foo(1, "2") def test2 = foo(List(), ListBuffer()) 虽
我对柯里化(Currying)和非柯里化(Currying)泛型函数之间类型检查的差异有点困惑: scala> def x[T](a: T, b: T) = (a == b) x: [T](a: T,
考虑一个类A,我如何编写一个具有与相同行为的模板 A& pretty(A& x) { /* make x pretty */ return x; } A pretty(A&& x) {
Eclipse 表示由于泛型类型橡皮擦,类型参数不允许使用 instanceof 操作。 我同意在运行时不会保留任何类型信息。但是请考虑以下类的通用声明: class SomeClass{ T
在 C++14 中: 对于任何整数或枚举类型 T 以及对于任何表达式 expr: 有没有区别: struct S { T t { expr }; }; 和 struct S { T t = { exp
我是一名优秀的程序员,十分优秀!