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);

效果图如下:


效果图

你可能感兴趣的:(POSTEK打印二维码、条码)