iOS_jc_printer_sdk/JCPrinterSDK/JCAPI.h

681 lines
22 KiB
C
Raw Normal View History

2023-10-26 09:46:24 +08:00
//
// JCAPI.h
// JCPrinterSDK
//
// Created by ydong on 2019/1/29.
// Copyright © 2019 ydong. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
/**
iOS9以上系统使用
*/
typedef NS_ENUM(NSUInteger, JCBarcodeMode){
//CODEBAR 1D format.
JCBarcodeFormatCodebar ,
//Code 39 1D format.
JCBarcodeFormatCode39 ,
//Code 93 1D format.
JCBarcodeFormatCode93 ,
//Code 128 1D format.
JCBarcodeFormatCode128 ,
//EAN-8 1D format.
JCBarcodeFormatEan8 ,
//EAN-13 1D format.
JCBarcodeFormatEan13 ,
//ITF (Interleaved Two of Five) 1D format.
JCBarcodeFormatITF ,
//UPC-A 1D format.
JCBarcodeFormatUPCA ,
//UPC-E 1D format.
JCBarcodeFormatUPCE
};
typedef NS_ENUM(NSUInteger,JCSDKCacheStatus){
JCSDKCacheWillPrinting,
JCSDKCachePrinting,
JCSDKCacheWillPause,
JCSDKCachePaused,
JCSDKCacheWillCancel,
JCSDKCacheCanceled,
JCSDKCacheWillDone,
JCSDKCacheDone,
JCSDKCacheWillResume,
JCSDKCacheResumed,
} ;
typedef NS_ENUM(NSUInteger,JCSDKCammodFontType) {
JCSDKCammodFontTypeStandard = 0,
JCSDKCammodFontTypeFreestyleScript,
JCSDKCammodFontTypeOCRA,
JCSDKCammodFontTypeHelveticaNeueLTPro,
JCSDKCammodFontTypeTimesNewRoman,
JCSDKCammodFontTypeMICR,
JCSDKCammodFontTypeTerU24b,
JCSDKCammodFontTypeSimpleChinese16Point = 55,
JCSDKCammodFontTypeSimpleChinese24Point
};
typedef NS_ENUM(NSUInteger,JCSDKCammodRotation) {
JCSDKCammodRotationDefault = 0,
JCSDKCammodRotation90 = 90,
JCSDKCammodRotation180 = 180,
JCSDKCammodRotation270 = 270
};
typedef NS_ENUM(NSUInteger,JCSDKCammodGraphicsType) {
JCSDKCammodGraphicsTypeHorizontalExt ,
JCSDKCammodGraphicsTypeVerticalExt,
JCSDKCammodGraphicsTypeHorizontalZip,
JCSDKCammodGraphicsTypeVerticalZip
};
typedef void (^DidOpened_Printer_Block) (BOOL isSuccess) ;
typedef void (^DidPrinted_Block) (BOOL isSuccess) ;
typedef void (^PRINT_INFO) (NSString * printInfo) ;
typedef void (^PRINT_STATE) (BOOL isSuccess) ;
typedef void (^PRINT_DIC_INFO) (NSDictionary * printDicInfo) ;
typedef void (^JCSDKCACHE_STATE) (JCSDKCacheStatus status) ;
@interface JCAPI : NSObject
/// @{@"serial":@"V1.0.0",@"date":@"2021/05/06",@"description":@"描述"}
+ (NSDictionary *)version;
/// 设置连接的打印机厂商id,需要在连接之前设置
/// id: 缺省0 1-精臣系。 2-B3系。 3-B11系。 4-T2系
/// @param printerFactoryId 厂商id
+ (void)setPrinterFactoryId:(NSInteger)printerFactoryId;
/// 设置第三方接入的对象类名
/// @param className 类名必须遵守JC_MyPrinterProtocol协议
+ (void)setPrinterFactoryTool:(NSString *)className;
/**
/Wi-Fi获取搜索到的打印机列表
wifi回调 @[@{@"ipAdd":@"ip地址", @"bleName":@"蓝牙名字"}]
@param isWifi YES:Wi-FiNO为搜索蓝牙
@param completion block(printerName参数)
*/
+ (void)scanPrinterNames:(BOOL)isWifi completion:(void(^)(NSArray *scanedPrinterNames))completion;
/**
@param printerName
@param completion
*/
+ (void)openPrinter:(NSString *)printerName
completion:(DidOpened_Printer_Block)completion;
/**
,使,@/@0,
hBit = value/256
lBit = value%256
B3S: hBit/lBit = 1
D11: hBit/lBit = 2
B21: hBit = 3
{
L2B: lBit = 1
L2W: lBit = 2
C2B: lBit = 3
C2W: lBit = 4
C3B: lBit = 5
C3W: lBit = 6
}
P1: hBit/lBit = 4
B16: hBit/lBit = 7
@return
*/
+(NSInteger )printerTypeInfo;
/**
*/
+ (void)closePrinter;
/**
/Wi-Fi获取当前连接的打印机名称Wi-Fi为ip地址
@return
*/
+ (NSString *)connectingPrinterName;
/**
/Wi-Fi连接状态
@return 2Wi-Fi10
*/
+ (int)isConnectingState;
/**
/Wi-Fi设置打印机
@param state 20-30 @param type
21- 12, 3, 4- 5-:1,2,3
22- 1, 2, 3, 4, 5
23- 1, 2, 34-5-4
24-() 1
25-() 123
26- 1-2-
27- N分钟 1-4(
1:15min;
2:30min;
3:60min(D11为45分钟);
4:(D11为60分钟)
)
28- 1
29- 1
20-,T2支持 1- 2-()
30-(0-5)
31-
@param completion
*/
+ (void)setPrintState:(NSInteger)state type:(NSInteger)type sucess:(PRINT_DIC_INFO)completion;
/**
/Wi-Fi获取打印机信息b11系列只有9&12
@param type 1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-:----()
14-
15-(b21打印机,V2.11d11系列3.28)
16-(b21打印机)
19-mac地址
20-(1 2)
21-
@param completion @"UNRESOPN_ERROR"
*/
+ (void)getPrintInfo:(NSInteger)type sucess:(PRINT_DIC_INFO)completion;
/**
@param completion
@param arg 10,+ (void)getPrintInfo:(NSInteger)type sucess:(PRINT_DIC_INFO)completion所支持的type类型arg对应的健值对
*/
+ (void)getInfosWithComplete:(PRINT_DIC_INFO)completion fromArgs:(NSInteger)arg, ...NS_REQUIRES_NIL_TERMINATION;
/**
/Wi-Fi是否支持盒盖状态检测
@return YES:NO:
*/
+ (BOOL)isSupportPrintCoverStatus;
/**
/Wi-Fi盒盖状态改变返回()
@param completion 01
@param checkPaperBlock 01
@return YES:NO:
*/
+ (BOOL)getPrintCoverStatusChange:(PRINT_INFO)completion withCheckPrinterHavePaperBlock:(PRINT_INFO)checkPaperBlock;
/**
@param completion
@{
@"1": -0/1
@"2": -1/2/3/4
@"3": -0/1
@"5": -0/1
}
@return YES:NO:
*/
+ (BOOL)getPrintStatusChange:(PRINT_DIC_INFO)completion;
/**
/Wi-Fi是否支持缺纸检测等功能app没有用到具体功能接口
@return YES:NO:
*/
+ (BOOL)isSupportNOPaper;
/**
p1打印机打印前传入总打印份数,startDraw:height:orientation:/startJob之前调用
@param totalQuantityOfPrints
*/
+ (void)setTotalQuantityOfPrints:(NSInteger)totalQuantityOfPrints;
/**
/Wi-Fi生成带延长线条码最小宽度,
@param text
@param barcodeMode
@param isExtension 线:YES为带NO未不带
@return
*/
+ (NSInteger)getBarCodeWidth:(NSString *)text codeFormat:(JCBarcodeMode)barcodeMode isExtension:(BOOL)isExtension;
/**
/Wi-Fi生成二维码最小宽度,
@param text
@return /
*/
+ (NSInteger)getQRCodeWidth:(NSString *)text;
/// 0-正常1-不支持的类型2-数据异常3-长度不符4-字符不符5-校验码不符
/// @param barcodeType 条码类型(20-28)
/// @param content 传入的条码数据
+ (int)barcodeFormatCheck:(int)barcodeType content:(NSString*)content ;
/// 0-正常1-不支持的类型2-数据异常3-长度不符4-字符不符
/// @param qrcodeType 条码类型(31-34)
/// @param content 传入的二维码数据
+ (int)qrcodeFormatCheck:(int)qrcodeType content:(NSString*)content;
/**
/Wi-Fi返回处理后的条码内容
@param text
@param barcodeMode
@return @"":
*/
+ (NSString *)dealBarCodeText:(NSString *)text withBarcodeMode:(JCBarcodeMode)barcodeMode;
/**
/Wi-Fi获取第几页预览图(print:)
@param index 0
@return
*/
+ (UIImage *)previewImage:(NSInteger)index;
/// 打印时获取预览图
+ (UIImage *)getPrintPreviewImage;
/**
/Wi-Fi图片直接生成预览图图片
@param image
@param width
@param height
@param orientation 0909018018027090
@return
*/
+ (UIImage *)drawpreviewImagFromImage:(UIImage *)image
width:(CGFloat)width
height:(CGFloat)height
orientation:(NSInteger)orientation;
/// 图像二期打印json数据
/// @param printData json数据
/// @param printerJson 打印机边距信息
/// @param onePageNumvers 单页要打印的份数
/// @param completion 回调
+ (void)print:(NSString *)printData printAddJson:(NSDictionary *)printerJson withOnePageNumbers:(int)onePageNumvers withComplete:(DidPrinted_Block)completion;
/**
/Wi-Fi取消打印()
@param completion
*/
+ (void)cancelJob:(DidPrinted_Block)completion;
/**
/Wi-Fi打印完成()
@param completion
*/
+ (void)endPrint:(DidPrinted_Block)completion;
/**
/Wi-Fi打价器打印完成的份数(app做超时重置状态)
@param count
@{
@"totalCount":@"总打印的张数计数" //返回必带的key
@"pageCount":@"当前打印第PageNo页的第几份" //非必带
@"pageNO":@"当前打印第几页" //非必带
@"tid":@"写入rfid返回的tid码" //非必带
@"carbonUsed":@"碳带使用量,单位毫米" //非必带
}
*/
+ (void)getPrintingCountInfo:(PRINT_DIC_INFO)count;
/**
/Wi-Fi异常接收()
@param error 1:,
2:,
3:,
4:,
5:,
6:,
-B3//,
7:,
8:,
9-(()/)
10-
11-
12.
13-
14-
15-
16-
17-
18-
19-,
20-Rfid失败
21-
(0++)
22-
23-
24-
25-
26-json参数错误(pc)
27-
28-
29-RFID标签进行非RFID模式打印时
30-
31-
32-()
33-()
34-()
35-(T2阻断正常打印)
36-(T2未放纸)
37-(T2无法通过指令恢复)
*/
+ (void)getPrintingErrorInfo:(PRINT_INFO)error;
/**
/Wi-Fi像素转毫米()
@param pixel
@return
*/
+ (CGFloat)pixelToMm:(CGFloat)pixel;
/**
/Wi-Fi毫米转像素()
@param mm
@return
*/
+ (CGFloat)mmToPixel:(CGFloat)mm;
/**
/Wi-Fi打印机分辨率
@return ()
*/
+ (NSInteger)printerResolution;
+ (float)printerMulityDpiToMm;
/// 设置字体路径
/// @param fontFamilyPath 路径
+(void) initImageProcessing:(NSString *) fontFamilyPath error:(NSError **)error;
/// 准备打印
/// @param blackRules 设置浓度
/// @param paperStyle 设置纸张
/// @param completion 回调
+ (void)startJob:(int)blackRules
withPaperStyle:(int)paperStyle
withCompletion:(DidPrinted_Block)completion;
/// 图像二期毫米转像素
/// @param mm 毫米
/// @param scaler 倍率
+ (int) mmToPixel:(float)mm scaler:(float)scaler;
/// 图像二期像素转毫米
/// @param pixel 像素
/// @param scaler 倍率
+ (float) pixelToMm:(int)pixel scaler:(float)scaler;
/// 获取倍率
/// @param templatePhysical 屏幕物理尺寸
/// @param screenDisplaySize 屏幕分辨率
+ (float)getDisplayMultiple:(float)templatePhysical templateDisplayWidth:(int)screenDisplaySize;
/// 毫米转英寸
/// @param mm 毫米
+(float) mmToInch:(float) mm;
/// 英寸转毫米
/// @param inch 英寸
+(float) inchToMm:(float) inch;
+(void)didReadSDKCacheStatus:(JCSDKCACHE_STATE)status;
+(void)setPrintWithCache:(BOOL)startCache;
/// 是否支持RFID写入功能
+(BOOL)isSupportWriteRFID;
/// 绘制画板
/// @param width 宽
/// @param height 高
/// @param horizontalShift 水平偏移
/// @param verticalShift 竖直偏移
/// @param rotate 旋转角度
/// @param font 使用字体路径,缺省输入nil
+(void)initDrawingBoard:(float)width
withHeight:(float)height
withHorizontalShift:(float)horizontalShift
withVerticalShift:(float)verticalShift
rotate:(int) rotate
font:(NSString*)font;
/// 绘制文本
/// @param x 水平起点
/// @param y 竖直起点
/// @param w 宽
/// @param h 高
/// @param text 内容
/// @param fontFamily 字体
/// @param fontSize 字体大小
/// @param rotate 旋转
/// @param textAlignHorizonral 文本水平对齐方式 0:左对齐 1:居中对齐 2:右对齐
/// @param textAlignVertical 文本竖直对齐方式 0:顶对齐 1:垂直居中 2:底对齐
/// @param lineMode 换行方式
/// @param letterSpacing 字体间隔
/// @param lineSpacing 行间隔
/// @param fontStyles [@1,@1,@1,@1] 斜体,加粗,下划线,删除下划线
+(BOOL)drawLableText:(float)x
withY:(float)y
withWidth:(float)w
withHeight:(float)h
withString:(NSString *)text
withFontFamily:(NSString *)fontFamily
withFontSize:(float)fontSize
withRotate:(int)rotate
withTextAlignHorizonral:(int)textAlignHorizonral
withTextAlignVertical:(int)textAlignVertical
withLineMode:(int)lineMode
withLetterSpacing:(float)letterSpacing
withLineSpacing:(float)lineSpacing
withFontStyle:(NSArray <NSNumber *>*)fontStyles;
/// 绘制条码
/// @param x 水平坐标
/// @param y 垂直坐标
/// @param w 标贴宽度,单位mm
/// @param h 标贴高度,单位mm
/// @param text 文本内容
/// @param fontSize 文本字号
/// @param rotate 旋转角度仅支持0,90,180,270
/// @param codeType 一维码类型 20:CODE128 21:UPC-A 22:UPC-E 23:EAN8 24:EAN13 25:CODE93 26:CODE39 27:CODEBAR 28:ITF25
/// @param textHeight 文本高度
/// @param textPosition 文本位置int 一维码文字识别码显示位置 0:下方显示 1:上方显示 2:不显示
+(BOOL)drawLableBarCode:(float)x
withY:(float)y
withWidth:(float)w
withHeight:(float)h
withString:(NSString *)text
withFontSize:(float)fontSize
withRotate:(int)rotate
withCodeType:(int)codeType
withTextHeight:(float)textHeight
withTextPosition:(int)textPosition;
/// 绘制二维码
/// @param x 水平坐标
/// @param y 垂直坐标
/// @param w 标贴宽度,单位mm
/// @param h 标贴高度,单位mm
/// @param text 文本内容
/// @param rotate 旋转角度仅支持0,90,180,270
/// @param codeType 二维码类型 31:QR_CODE 32:PDF417 33:DATA_MATRIX 34:AZTEC
+(BOOL)drawLableQrCode:(float)x
withY:(float)y
withWidth:(float)w
withHeight:(float)h
withString:(NSString *)text
withRotate:(int)rotate
withCodeType:(int)codeType;
/// 绘制线条
/// @param x 水平坐标
/// @param y 垂直坐标
/// @param w 标贴宽度,单位mm
/// @param h 标贴高度,单位mm
/// @param rotate 旋转角度仅支持0,90,180,270
/// @param lineType 线条类型 1:实线 2:虚线类型,虚实比例1:1
/// @param dashWidth 线条为虚线宽度,【实线段长度,空线段长度】
+(BOOL)DrawLableLine:(float)x
withY:(float)y
withWidth:(float)w
withHeight:(float)h
withRotate:(int)rotate
withLineType:(int)lineType
withDashWidth:(NSArray <NSNumber *>*)dashWidth;
/// 绘制形状
/// @param x 水平坐标
/// @param y 垂直坐标
/// @param w 标贴宽度,单位mm
/// @param h 标贴高度,单位mm
/// @param lineWidth 线条类型
/// @param cornerRadius 图像圆角
/// @param rotate 旋转角度仅支持0,90,180,270
/// @param graphType 图形类型
/// @param lineType 线条类型 1:实线 2:虚线类型,虚实比例1:1
/// @param dashWidth 线条为虚线宽度,【实线段长度,空线段长度】
+(BOOL)DrawLableGraph:(float)x
withY:(float)y
withWidth:(float)w
withHeight:(float)h
withLineWidth:(float)lineWidth
withCornerRadius:(float)cornerRadius
withRotate:(int)rotate
withGraphType:(int)graphType
withLineType:(int)lineType
withDashWidth:(NSArray <NSNumber *>*)dashWidth;
/// 绘制图片
/// @param x 水平坐标
/// @param y 垂直坐标
/// @param w 标贴宽度,单位mm
/// @param h 标贴高度,单位mm
/// @param imageData 图像base64数据
/// @param rotate 旋转角度仅支持0,90,180,270
/// @param imageProcessingType 处理算法
/// @param imageProcessingValue 阈值
+(BOOL)DrawLableImage:(float)x
withY:(float)y
withWidth:(float)w
withHeight:(float)h
withImageData:(NSString *)imageData
withRotate:(int)rotate
withImageProcessingType:(int)imageProcessingType
withImageProcessingValue:(float)imageProcessingValue;
+(NSString *)GenerateLableJson;
/// 获取预览图
/// @param displayScale 倍率
/// @param error 出错返回的错误码
+(UIImage *)generateImagePreviewImage:(float)displayScale error:(NSError **)error;
/// 开始打印
/// @param printData 打印数据
/// @param onePageNumvers 打印份数
/// @param completion 回调
+ (void)commit:(NSString *)printData
withOnePageNumbers:(int)onePageNumvers
withComplete:(DidPrinted_Block)completion;
#pragma mark ###################双色打印##################
/// 是否是双色打印机,需要连接成功之后调用
+(int) getPrinterColorType;
/// 准备打印
/// @param blackRules 设置浓度
/// @param paperStyle 设置纸张
/// @param completion 回调
+ (void)startJob:(int)blackRules
withPaperStyle:(int)paperStyle
withColorType:(int)colorType
withCompletion:(DidPrinted_Block)completion;
@end