博思得(POSTEK)打标签程序DEMO(C++版本)

博思得(POSTEK)打标签程序DEMO(C++版本)


一、头文件

function.h

#ifndef FUNCTION_H
#define FUNCTION_H

typedef int (*fPTK_OpenUSBPort)(unsigned int);
typedef int (*fPTK_CloseUSBPort)();
typedef int (*fPTK_PrintLabel)(unsigned int,unsigned int);
typedef int (*fPTK_DrawText)(unsigned int , unsigned int ,unsigned int , unsigned int ,
                             unsigned int , unsigned int ,char , const char* );
typedef int (*fPTK_ClearBuffer)();
typedef int (*fPTK_SetLabelHeight)(unsigned int lheight, unsigned int gapH,
                                             int gapOffset,bool bFlag);
typedef int (*fPTK_SetLabelWidth)(unsigned int lwidth);
typedef int (*fPTK_DrawText_TrueType)(unsigned int x, unsigned int y, unsigned int FHeight, unsigned int
FWidth,const char* FType, unsigned int Fspin, unsigned int FWeight, bool FItalic,bool FUnline, bool FStrikeOut,
const char* data);
typedef int (*fPTK_DrawLineOr)(unsigned int px,unsigned int py,
                            unsigned int plength,unsigned int pH);
typedef int (*fPTK_SetDirection)(char direct);
typedef int (*fPTK_SetDarkness)(unsigned  int id);
typedef int (*fPTK_SetPrintSpeed)(unsigned int px);
typedef int (*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,const char* pstr);
typedef int (*fPTK_SetCharSets)(unsigned int BitValue,char CharSets,const char* CountryCode);



#endif // FUNCTION_H

二、主程序

main.cpp

#include "function.h"
#include <iostream>
#include <windows.h>
HMODULE hDLL = LoadLibrary("CDFPSK.dll");//加载dll,将dll放在该工程根路径即可
fPTK_OpenUSBPort    PTK_OpenUSBPort     =   NULL;
fPTK_CloseUSBPort   PTK_CloseUSBPort    =   NULL;
fPTK_PrintLabel     PTK_PrintLabel      =   NULL;
fPTK_DrawText       PTK_DrawText        =   NULL;
fPTK_ClearBuffer    PTK_ClearBuffer     =   NULL;
fPTK_SetLabelHeight PTK_SetLabelHeight  =   NULL;
fPTK_SetLabelWidth  PTK_SetLabelWidth  =    NULL;
fPTK_DrawText_TrueType PTK_DrawText_TrueType=    NULL;
fPTK_DrawLineOr       PTK_DrawLineOr  =     NULL;
fPTK_SetDirection       PTK_SetDirection  =   NULL;
fPTK_SetDarkness   PTK_SetDarkness   =      NULL;
fPTK_SetPrintSpeed  PTK_SetPrintSpeed   =    NULL;
fPTK_DrawBar2D_QR  PTK_DrawBar2D_QR    =     NULL;
fPTK_SetCharSets   PTK_SetCharSets    =     NULL;

int main() {
    PTK_CloseUSBPort = (fPTK_CloseUSBPort)GetProcAddress(hDLL,"PTK_CloseUSBPort");
    PTK_OpenUSBPort= (fPTK_OpenUSBPort)GetProcAddress(hDLL,"PTK_OpenUSBPort");
    PTK_ClearBuffer= (fPTK_ClearBuffer)GetProcAddress(hDLL,"PTK_ClearBuffer");
    PTK_SetCharSets= (fPTK_SetCharSets)GetProcAddress(hDLL,"PTK_SetCharSets");
    PTK_SetLabelHeight= (fPTK_SetLabelHeight)GetProcAddress(hDLL,"PTK_SetLabelHeight");
    PTK_ClearBuffer= (fPTK_ClearBuffer)GetProcAddress(hDLL,"PTK_ClearBuffer");
    PTK_SetLabelWidth= (fPTK_SetLabelWidth)GetProcAddress(hDLL,"PTK_SetLabelWidth");
    PTK_SetLabelHeight= (fPTK_SetLabelHeight)GetProcAddress(hDLL,"PTK_SetLabelHeight");
    PTK_SetDirection= (fPTK_SetDirection)GetProcAddress(hDLL,"PTK_SetDirection");
    PTK_SetDarkness= (fPTK_SetDarkness)GetProcAddress(hDLL,"PTK_SetDarkness");
    PTK_SetPrintSpeed= (fPTK_SetPrintSpeed)GetProcAddress(hDLL,"PTK_SetPrintSpeed");

    PTK_DrawText_TrueType= (fPTK_DrawText_TrueType)GetProcAddress(hDLL,"PTK_DrawText_TrueType");
    PTK_DrawLineOr= (fPTK_DrawLineOr)GetProcAddress(hDLL,"PTK_DrawLineOr");
    PTK_DrawText= (fPTK_DrawText)GetProcAddress(hDLL,"PTK_DrawText");
    PTK_DrawBar2D_QR= (fPTK_DrawBar2D_QR)GetProcAddress(hDLL,"PTK_DrawBar2D_QR");
    PTK_PrintLabel= (fPTK_PrintLabel)GetProcAddress(hDLL,"PTK_PrintLabel");

   
    PTK_OpenUSBPort(255);
    PTK_ClearBuffer();
    PTK_SetCharSets (8,'G',"001");         //第二个参数设置为字符集编码方式,G为GBK;U为UTF-8
    PTK_SetLabelHeight(240, 20, 0, false);  // 设置打印标签高度和间隙或黑标等(单位为像素点)
    PTK_SetLabelWidth(720);   // 设置打印标签宽度(单位为像素点)
    PTK_SetDirection('B');
    PTK_SetDarkness(10);            // 设置打印头发热温度
    PTK_SetPrintSpeed(5);           // 设置打印机打印速度
    PTK_DrawText_TrueType(50, 30, 48, 0,"黑体", 1, 400, false,false,false,"POSTEK博思得黑体");

    PTK_DrawLineOr(58, 130, 500, 3);
    PTK_DrawText(30, 80, 0, 6, 2, 2, 'N', "测试打印文本6,ABC123");
    PTK_DrawBar2D_QR(50, 150, 180, 180, 0, 3, 2, 0, 0, "Postek Electronics Co., Ltd.");
    PTK_PrintLabel(1,1);
    return 1;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值