实例介绍
【实例简介】
【实例截图】

【核心代码】
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace CSHARP_POSTEK_PRINT
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
PrintLab.OpenPort("POSTEK G-2108");//打开打印机端口
PrintLab.PTK_ClearBuffer(); //清空缓冲区
PrintLab.PTK_SetPrintSpeed(4); //设置打印速度
PrintLab.PTK_SetDarkness(10); //设置打印黑度
PrintLab.PTK_SetLabelHeight(600, 16); //设置标签的高度和定位间隙\黑线\穿孔的高度
PrintLab.PTK_SetLabelWidth(800); //设置标签的宽度
for (int i = 1; i <= 1; i )
{
//PrintLab.PTK_DrawTextTrueTypeW(200, 300, 40, 40, "宋体", 1, 400, false, true, true, "1", "12456789");//打印一行 TrueType Font文字
//PrintLab.PTK_DrawBarcode(100, 20, 0, "1", 3, 3, 80, 'N', "12345");//打印一个条码
//PrintLab.PTK_SetPagePrintCount(1, 1);//命令打印机执行打印工作
// 画矩形
PrintLab.PTK_DrawRectangle(58, 15, 3, 558, 312);
// 打印PCX图片 方式一
PrintLab.PTK_PcxGraphicsDel("PCX");
PrintLab.PTK_PcxGraphicsDownload("PCX", "logo.pcx");
PrintLab.PTK_DrawPcxGraphics(80, 20, "PCX");
// 打印PCX图片 方式二
// PTK_PrintPCX(80,30,pchar('logo.pcx'));
// 打印一个条码;
PrintLab.PTK_DrawBarcode(300, 23, 0, "1", 2, 2, 50, 'B', "123456789");
// 画表格分割线
PrintLab.PTK_DrawLineOr(58, 100, 500, 3);
// 打印一行TrueTypeFont文字;
PrintLab.PTK_DrawTextTrueTypeW(80, 120, 40, 0, "Arial", 1, 400, false, false, false, "A1", "TrueTypeFont");
// 打印一行文本文字(内置字体或软字体);
PrintLab.PTK_DrawText(80, 168, 0, 3, 1, 1, 'N', "Internal Soft Font");
// 打印PDF417码
PrintLab.PTK_DrawBar2D_Pdf417(80, 210, 400, 300, 0, 0, 3, 7, 10, 2, 0, 0, "123456789");//PDF417码
// 打印QR码
PrintLab.PTK_DrawBar2D_QR(420, 120, 180, 180, 0, 3, 2, 0, 0, "Postek Electronics Co., Ltd.");
// 打印一行TrueTypeFont文字旋转;
PrintLab.PTK_DrawTextTrueTypeW(520, 102, 22, 0, "Arial", 2, 400, false, false, false, "A2", "www.postek.com.cn");
PrintLab.PTK_DrawTextTrueTypeW(80, 260, 19, 0, "Arial", 1, 700, false, false, false, "A3", "Use different ID_NAME for different Truetype font objects");
// 命令打印机执行打印工作
PrintLab.PTK_PrintLabel(1, 1);
PrintLab.ClosePort();//关闭打印机端口
}
}
}
}
public class PrintLab
{
[DllImport("WINPSK.dll")]
public static extern int OpenPort(string printname);
[DllImport("WINPSK.dll")]
public static extern int PTK_SetPrintSpeed(uint px);
[DllImport("WINPSK.dll")]
public static extern int PTK_SetDarkness(uint id);
[DllImport("WINPSK.dll")]
public static extern int ClosePort();
[DllImport("WINPSK.dll")]
public static extern int PTK_PrintLabel(uint number, uint cpnumber);
[DllImport("WINPSK.dll")]
public static extern int PTK_DrawTextTrueTypeW
(int x, int y, int FHeight,
int FWidth, string FType,
int Fspin, int FWeight,
bool FItalic, bool FUnline,
bool FStrikeOut,
string id_name,
string data);
[DllImport("WINPSK.dll")]
public static extern int PTK_DrawBarcode(uint px,
uint py,
uint pdirec,
string pCode,
uint pHorizontal,
uint pVertical,
uint pbright,
char ptext,
string pstr);
[DllImport("WINPSK.dll")]
public static extern int PTK_SetLabelHeight(uint lheight, uint gapH);
[DllImport("WINPSK.dll")]
public static extern int PTK_SetLabelWidth(uint lwidth);
[DllImport("WINPSK.dll")]
public static extern int PTK_ClearBuffer();
[DllImport("WINPSK.dll")]
public static extern int PTK_DrawRectangle(uint px, uint py, uint thickness, uint pEx, uint pEy);
[DllImport("WINPSK.dll")]
public static extern int PTK_DrawLineOr(uint px, uint py, uint pLength, uint pH);
[DllImport("WINPSK.dll")]
public static extern int PTK_DrawBar2D_QR( uint x,uint y, uint w, uint v,uint o, uint r,uint m, uint g,uint s,string pstr);
[DllImport("WINPSK.dll")]
public static extern int PTK_DrawBar2D_Pdf417(uint x, uint y,uint w, uint v,uint s, uint c,uint px, uint py,uint r, uint l,uint t, uint o,string pstr);
[DllImport("WINPSK.dll")]
public static extern int PTK_PcxGraphicsDel(string pid);
[DllImport("WINPSK.dll")]
public static extern int PTK_PcxGraphicsDownload(string pcxname, string pcxpath);
[DllImport("WINPSK.dll")]
public static extern int PTK_DrawPcxGraphics(uint px, uint py, string gname);
[DllImport("WINPSK.dll")]
public static extern int PTK_DrawText(uint px,uint py,uint pdirec,uint pFont,uint pHorizontal, uint pVertical,char ptext, string pstr);
}
标签: POSTEK
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论