POSTEK打印二维码、条码

PTK_DrawBarcode函数作用是打印一个条码。

POSTEKPPCSAPI 函数手册链接https://wenku.baidu.com/view/9917cf5e804d2b160b4ec044.html
函数可查此API

标签打印方向

标签对应x轴、y轴

原型:

条码
int PTK_DrawBarcode(unsigned int px,
unsigned int py,
unsigned int pdirec,
LPTSTR pCode,
unsigned int pHorizontal,
unsigned int pVertical,
unsigned int pbright,
char ptext,
LPTSTR pstr);

如图:


条码

二维码
PTK_DrawBar2D_QR(
unsigned int x,
unsigned int y,
unsigned int w,
unsigned int v,
unsigned int o,
unsigned int r,
unsigned int m,
unsigned int g,
unsigned int s,
LPTSTR pstr);

errorcode = PTK_DrawBar2D_QR(45, 18, 70, 70, 0, 3, 1, 0, 0,pBuf);


二维码

完整代码段:
PTKPRN.h文件


//CDFPSK.DLL函数声明头文件
#ifndef _PCDFPSK_H
#define _PCDFPSK_H
//CDFPSK DLL Function Declaration start
typedef int (__stdcall *fOpenPort)(LPCTSTR printername);
typedef int (__stdcall *fPTK_SetDarkness)(unsigned  int id);
typedef int (__stdcall *fPTK_SetPrintSpeed)(unsigned int px);
typedef int (__stdcall *fClosePort)(void);
typedef int (__stdcall *fPTK_PrintLabel)(unsigned int number,
                                         unsigned int cpnumber);
typedef int (__stdcall *fPTK_DrawBarcode)(unsigned  int px,
                                unsigned int  py,
                                unsigned int  pdirec,
                                LPTSTR        pCode,
                                unsigned int  pHorizontal,
                                unsigned int  pVertical,
                                unsigned int pbright,
                                char ptext,
                                LPTSTR pstr);
typedef int (__stdcall *fPTK_DrawBar2D_QR)(
                                unsigned int x,
                                unsigned int y,
                                unsigned int w,
                                unsigned int v,
                                unsigned int o,
                                unsigned int r,
                                unsigned int m,
                                unsigned int g,
                                unsigned int s,
                                LPTSTR pstr);
//typedef int (__stdcall *fPTK_DrawBar2D_Pdf417)(
//                              unsigned int x,
//                              unsigned int y,
//                              unsigned int w,
//                              unsigned int v,
//                              unsigned int s,
//                              unsigned int c,
//                              unsigned int px,
//                              unsigned int py,
//                              unsigned int r,
//                              unsigned int l,
//                              unsigned int t,
//                              unsigned int o,
//                              LPTSTR pstr);
typedef int (__stdcall *fPTK_DrawTextTrueTypeW)
                                    (int x,int y,int FHeight,
                                    int FWidth,LPCTSTR FType,
                                    int Fspin,int FWeight,
                                    BOOL FItalic,BOOL FUnline,
                                    BOOL FStrikeOut,
                                    LPCTSTR id_name,
                                    LPCTSTR data);
typedef int (__stdcall *fPTK_SetLabelHeight)
                        (unsigned int lheight, unsigned int gapH);
typedef int (__stdcall *fPTK_SetLabelWidth)(unsigned int lwidth);
typedef int (__stdcall *fPTK_ClearBuffer)();
typedef int (__stdcall *fPTK_DrawLineXor)(unsigned int x,unsigned int y,unsigned int pbyte,unsigned int pH);


fOpenPort OpenPort = NULL;
fPTK_SetDarkness PTK_SetDarkness = NULL;
fPTK_DrawTextTrueTypeW PTK_DrawTextTrueTypeW = NULL;
fPTK_SetPrintSpeed PTK_SetPrintSpeed = NULL;
fClosePort ClosePort = NULL;
fPTK_PrintLabel PTK_PrintLabel = NULL;
fPTK_DrawBarcode PTK_DrawBarcode = NULL;
fPTK_DrawBar2D_QR PTK_DrawBar2D_QR = NULL;
fPTK_SetLabelHeight PTK_SetLabelHeight = NULL;
fPTK_SetLabelWidth PTK_SetLabelWidth = NULL;
fPTK_ClearBuffer PTK_ClearBuffer = NULL;
fPTK_DrawLineXor PTK_DrawLineXor = NULL;
//CDFPSK DLL Function Declaration end
#endif

调用:

gt1=LoadLibrary("WINPSK.dll");
    OpenPort = (fOpenPort)GetProcAddress(gt1,"OpenPort");
    ClosePort = (fClosePort)GetProcAddress(gt1,"ClosePort");
    PTK_DrawBarcode = (fPTK_DrawBarcode)GetProcAddress(gt1,"PTK_DrawBarcode");
    //
    PTK_DrawBar2D_QR = (fPTK_DrawBar2D_QR)GetProcAddress(gt1,"PTK_DrawBar2D_QR");
    PTK_SetLabelHeight = (fPTK_SetLabelHeight)GetProcAddress(gt1,"PTK_SetLabelHeight");
    PTK_PrintLabel = (fPTK_PrintLabel)GetProcAddress(gt1,"PTK_PrintLabel");
    PTK_SetDarkness = (fPTK_SetDarkness)GetProcAddress(gt1,"PTK_SetDarkness");
    PTK_SetPrintSpeed = (fPTK_SetPrintSpeed)GetProcAddress(gt1,"PTK_SetPrintSpeed");
    PTK_SetLabelWidth = (fPTK_SetLabelWidth)GetProcAddress(gt1,"PTK_SetLabelWidth");
    PTK_ClearBuffer = (fPTK_ClearBuffer)GetProcAddress(gt1,"PTK_ClearBuffer");
    PTK_DrawTextTrueTypeW = (fPTK_DrawTextTrueTypeW)GetProcAddress(gt1,"PTK_DrawTextTrueTypeW");
    PTK_DrawLineXor = (fPTK_DrawLineXor)GetProcAddress(gt1,"PTK_DrawLineXor");
////////////////////////////
if (errorcode!=0)  {break;}
        errorcode = PTK_SetLabelHeight (120,10);
        if(errorcode != 0) {break;}
        errorcode = PTK_SetLabelWidth (480);
        if(errorcode != 0) {break;}
        errorcode = PTK_SetDarkness( 6 );
        if(errorcode != 0) {break;}
        errorcode = PTK_SetPrintSpeed( 5 );
        if(errorcode != 0) {break;} 
        errorcode = PTK_DrawBar2D_QR(45, 18, 70, 70, 0, 3, 1, 0, 0,"6190101D0000769"); 
        if(errorcode != 0) {break;} 
        errorcode = PTK_DrawBar2D_QR(370, 18, 70, 70, 0, 3, 1, 0, 0,pBuf); 
        if(errorcode != 0) {break;}
        errorcode = PTK_DrawTextTrueTypeW (5,80,22,0,"Arial",1,400,0,0,0,"7",strtid);
        if(errorcode != 0) {break;} 
        errorcode = PTK_DrawTextTrueTypeW (320,80,22,0,"Arial",1,400,0,0,0,"8",strtid);

效果图如下:


效果图
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,830评论 5 468
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,992评论 2 376
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,875评论 0 331
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,837评论 1 271
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,734评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,091评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,550评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,217评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,368评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,298评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,350评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,027评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,623评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,706评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,940评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,349评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,936评论 2 341

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,689评论 0 3
  • ## 可重入函数 ### 可重入性的理解 若一个程序或子程序可以安全的被并行执行,则称其为可重入的;即当该子程序正...
    夏至亦韵阅读 695评论 0 0
  • 题目来源:1、中兴、华为、慧通、英华达、微软亚洲技术中心等中外企业面试题目;2、C 语言面试宝典(林锐《高质量编程...
    月震阅读 1,787评论 0 1
  • 在C语言中,五种基本数据类型存储空间长度的排列顺序是: A)char B)char=int<=float C)ch...
    夏天再来阅读 3,307评论 0 2
  • 因为年轻,对世界一无所知,却也因此对世界充满渴望。想看更广袤的天地,想体验不一样的人生,想成为自己想成为的自己。
    TMZ阅读 145评论 2 1