ZPL斑马语言,C#打印类实例

【代码】ZPL斑马语言,C#打印类实例。
摘要由CSDN通过智能技术生成
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
namespace Zebra
{
   
  /// <summary>
  /// ZPL帮助类
  /// </summary>
  public class ZebraHelper
  {
   
    /*
     * 打印中文先引用Fnthex32.dll
      dll控件常规安装方法(仅供参考):
      下面是32系统的注册bat文件
      可将下面的代码保存为“注册.bat“,放到dll目录,就会自动完成dll注册(win98不支持)。
      @echo 开始注册
      copy Fnthex32.dll %windir%\system32\
      regsvr32 %windir%\system32\Fnthex32.dll /s
      @echo Fnthex32.dll注册成功
      @pause
      下面是64系统的注册bat文件
      @echo 开始注册
      copy Fnthex32.dll %windir%\SysWOW64\
      regsvr32 %windir%\SysWOW64\Fnthex32.dll /s
      @echo Fnthex32.dll注册成功
      @pause
     *
     *
      ZebraHelper zh = new ZebraHelper();
      StringBuilder builder = new StringBuilder();
      builder.AppendLine(zh.ZPL_Start());
      builder.AppendLine(zh.ZPL_PageSet(40, 80));
      builder.AppendLine(zh.ZPL_DrawCHText("上善若水 厚德载物", "宋体", 40, 40, 0, 32, 0, 1, 0));
      builder.AppendLine(zh.ZPL_DrawBarcode(40, 150, 3, 2, 40, "111112222233333"));
      builder.AppendLine(zh.ZPL_DrawENText("111112222233333", "A", 30, 205, "N", 30, 50));
      builder.AppendLine(zh.ZPL_DrawRectangle(20,20,2,700,700));
      builder.AppendLine(zh.ZPL_End());
      string a = builder.ToString();
      //打印
      zh.CmdDos("c:\\c.txt", a);
     */
    public string ZPL_Start()
    {
   
      StringBuilder builder = new StringBuilder();
      builder.AppendLine("^XA"); //指令块的开始
      builder.AppendLine("^MD30"); //MD是设置色带颜色的深度
      return builder.ToString();
    }
    public string ZPL_End()
    {
   
      StringBuilder builder = new StringBuilder();
      builder.AppendLine("^XZ"); //指令块的结束
      return builder.ToString();
    }
    /// <summary>
    /// 设置打印标签纸边距
    /// </summary>
    /// <param name="printX">标签纸边距x坐标</param>
    /// <param name="printY">标签纸边距y坐标</param>
    /// <returns></returns>
    public string ZPL_PageSet(int printX, int printY)
    {
   
      StringBuilder builder = new StringBuilder();
      builder.AppendLine("^LH" + printX + "," + printY); //定义条码纸边距 80 10
      return builder.ToString();
    }
    /// <summary>
    /// 打印凭条设置
    /// </summary>
    /// <param name="width">凭条宽度</param>
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值