基本信息
源码名称:POSTEK二次开发接口
源码大小:0.10M
文件格式:.rar
开发语言:C#
更新时间:2020-08-07
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
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);
}