启锐标签打印机驱动

  • 启锐标签打印机驱动已关闭评论
  • A+
所属分类:远程解决方案
摘要

节//1.选择字体stringstrSelectFont=aryPrintContent[0];stringstrSize=strSelectFont.Substring(strSelectFont.IndexOf(“;”)+1);s

节
//1.选择字体
string strSelectFont = aryPrintContent[0];
string strSize = strSelectFont.Substring(strSelectFont.IndexOf(";") + 1);
string strFont = strSelectFont.Substring(strSelectFont.IndexOf("=") + 1, strSelectFont.IndexOf(";") - strSelectFont.IndexOf("=") - 1);
string strSelectFontSend = "\x1B\x21" + strSize + "\x1B\x4E" + strFont;

//2.设置切纸
string strCutPaper = "\x1D\x56\x42\x00";

//3.设置横向跳格
string strSpaceLine = "\x1B\x44\x02\x10\x22\x00";

//4.设置绝对打印位置
string strAbsolutePrint = "\x1B\x24\x0A\x0A";

//5.设置标签尺寸
string strLabelSize = "\x1D\x77\x03";

//6.设置标签间距
string strLabelSpace = "\x1D\x78\x01";

//7.设置国际字符集
string strCharSet = "\x1B\x52\x08";

//8.设置打印内容
string strPrintContent = aryPrintContent[1];

//9.设置打印数量
string strPrintNumber = "\x1B\x2A\x00\x00";

//10.设置标签结束
string strLabelEnd = "\x1D\x0A";

//11.拼接打印内容
string strContent = strSelectFontSend + strCutPaper + strSpaceLine + strAbsolutePrint + strLabelSize + strLabelSpace + strCharSet + strPrintContent + strPrintNumber + strLabelEnd;

//12.计算打印内容长度
int intLen = strContent.Length;
string strLen = Convert.ToString(intLen, 16);
if (strLen.Length == 1)
{
strLen = "000" + strLen;
}
else if (strLen.Length == 2)
{
strLen = "00" + strLen;
}
else if (strLen.Length == 3)
{
strLen = "0" + strLen;
}

//13.拼接打印命令
string strPrintCmd = "1B40" + strLen + strContent;

//14.进行发送
byte[] bytePrintCmd = Common.HexStringToByteArray(strPrintCmd);
return bytePrintCmd;
}

#endregion

#region 打印条码

///

/// 打印条码
///

/// X轴坐标
/// Y轴坐标
/// 条码内容
/// 条码高度
/// 条码宽度
/// HRI字体类型
/// HRI字体位置
///
public static string PrintBarcode(int intX, int intY, string strBarcode, int intHeight, int intWidth, int intHriFontType, int intHriFontPosition)
{
string strPrintContent = string.Empty;
if (intX 255)
{
intX = 255;
}
if (intY 255)
{
intY = 255;
}

//1.设置打印位置
string strPrintPosition = "\x1B\x24" + Convert.ToString(intY, 16).PadLeft(2, '0') + Convert.ToString(intX, 16).PadLeft(2, '0');

//2.设置条码高度
string strPrintHeight = "\x1D\x68" + Convert.ToString(intHeight, 16).PadLeft(2, '0');

//3.设置条码宽度
string strPrintWidth = "\x1D\x77" + Convert.ToString(intWidth, 16).PadLeft(2, '0');

//4.设置HRI字体类型
string strHriFontType = "\x1D\x66" + Convert.ToString(intHriFontType, 16);

//5.设置HRI字体位置
string strHriFontPosition = "\x1D\x48" + Convert.ToString(intHriFontPosition, 16);

//6.设置条码内容
string strBarcodeContent = "\x1D\x6B\x45" + Convert.ToString(strBarcode.Length, 16).PadLeft(2, '0') + strBarcode;

//7.拼接打印内容
strPrintContent = strPrintPosition + strPrintHeight + strPrintWidth + strHriFontType + strHriFontPosition + strBarcodeContent;

return strPrintContent;
}

#endregion

#region 打印图片

///

/// 打印图片
///

/// 图片路径
///
public static string PrintImage(string strPath)
{
string strPrintContent = string.Empty;

//1.将图片转换为16进制字符串
string strImage = Common.ImageToHexString(strPath);

//2.设置对齐方式
string strAlign = "\x1B\x61\x01";

//3.设置图片模式
string strMode = "\x1D\x2A\x00";

//4.设置图片大小
string strSize = "\x1D\x21\x01";

//5.设置图片内容
string strContent = "\x1D\x76\x30\x00" + Convert.ToString(strImage.Length / 2, 16).PadLeft(4, '0') + strImage;

//6.拼接打印内容
strPrintContent = strAlign + strMode + strSize + strContent;

return strPrintContent;
}

#endregion

#region 打印文本

///

/// 打印文本
///

/// <param name="

  • 在线技术客服
  • 扫一扫加微信 码上服务
  • weinxin
  • 微信公众号
  • 在线维修故障技术支持 有问必答
  • weinxin
ksjiexin