- 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/
#include using namespace std; class C{ private: int value; public: C(){ value = 0;
这个问题已经有答案了: What is the difference between char a[] = ?string?; and char *p = ?string?;? (8 个回答) 已关闭
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 此帖子已于 8 个月
除了调试之外,是否有任何针对 c、c++ 或 c# 的测试工具,其工作原理类似于将独立函数复制粘贴到某个文本框,然后在其他文本框中输入参数? 最佳答案 也许您会考虑单元测试。我推荐你谷歌测试和谷歌模拟
我想在第二台显示器中移动一个窗口 (HWND)。问题是我尝试了很多方法,例如将分辨率加倍或输入负值,但它永远无法将窗口放在我的第二台显示器上。 关于如何在 C/C++/c# 中执行此操作的任何线索 最
我正在寻找 C/C++/C## 中不同类型 DES 的现有实现。我的运行平台是Windows XP/Vista/7。 我正在尝试编写一个 C# 程序,它将使用 DES 算法进行加密和解密。我需要一些实
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
有没有办法强制将另一个 窗口置于顶部? 不是应用程序的窗口,而是另一个已经在系统上运行的窗口。 (Windows, C/C++/C#) 最佳答案 SetWindowPos(that_window_ha
假设您可以在 C/C++ 或 Csharp 之间做出选择,并且您打算在 Windows 和 Linux 服务器上运行同一服务器的多个实例,那么构建套接字服务器应用程序的最明智选择是什么? 最佳答案 如
你们能告诉我它们之间的区别吗? 顺便问一下,有什么叫C++库或C库的吗? 最佳答案 C++ 标准库 和 C 标准库 是 C++ 和 C 标准定义的库,提供给 C++ 和 C 程序使用。那是那些词的共同
下面的测试代码,我将输出信息放在注释中。我使用的是 gcc 4.8.5 和 Centos 7.2。 #include #include class C { public:
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我的客户将使用名为 annoucement 的结构/类与客户通信。我想我会用 C++ 编写服务器。会有很多不同的类继承annoucement。我的问题是通过网络将这些类发送给客户端 我想也许我应该使用
我在 C# 中有以下函数: public Matrix ConcatDescriptors(IList> descriptors) { int cols = descriptors[0].Co
我有一个项目要编写一个函数来对某些数据执行某些操作。我可以用 C/C++ 编写代码,但我不想与雇主共享该函数的代码。相反,我只想让他有权在他自己的代码中调用该函数。是否可以?我想到了这两种方法 - 在
我使用的是编写糟糕的第 3 方 (C/C++) Api。我从托管代码(C++/CLI)中使用它。有时会出现“访问冲突错误”。这使整个应用程序崩溃。我知道我无法处理这些错误[如果指针访问非法内存位置等,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我有一些 C 代码,将使用 P/Invoke 从 C# 调用。我正在尝试为这个 C 函数定义一个 C# 等效项。 SomeData* DoSomething(); struct SomeData {
这个问题已经有答案了: Why are these constructs using pre and post-increment undefined behavior? (14 个回答) 已关闭 6
我是一名优秀的程序员,十分优秀!