跳转到内容

CPCL SDK 完整索引

本索引按语言收录固定版本中该模块的全部命令参数源文件和枚举。EMAPI 收录命令工厂、载荷、会话和编解码入口;C 收录兼容接口。展开查看参数声明摘录,通过固定版本源码链接核对完整默认值、条件分支和序列化。标题中的命令头预览来自源码字面量,不是完整的指令格式。

声明保留实现中已有的差异。收录表示存在对应实现,不表示所有打印机都支持。发送前请查阅兼容性与验证。

查看协议说明 →

源文件数: 207.

cbar.dart

完整参数、默认值与命令编码

class CBar extends BasicCPCLArg<CBar> {
late int _x; //一维码起始横坐标
late int _y; //一维码起始纵坐标
late String _content; //条码内容
late int _lineWidth; //条码线宽度
late int _height; //条码高度
late CCodeType _codeType; //条码类型
late CCodeRotation _codeRotation;
CBar({
required int x,
required int y,
required String content,
required int lineWidth,
required int height,
CCodeType codeType = CCodeType.code128,
CCodeRotation codeRotation = CCodeRotation.rotation_0,
}) {
String header() {
cbattery.dart — 10 FF EF F3

完整参数、默认值与命令编码

class CBatteryVolume extends OnlyBinaryHeaderArg<CBatteryVolume> {
bool newline() {
cbold.dart — SETBOLD

完整参数、默认值与命令编码

class CBold extends BasicCPCLArg<CBold> {
late bool _bold; //是否粗体0:否; 1:是
CBold({
required bool bold,
}) {
String header() {
cbox.dart — BOX

完整参数、默认值与命令编码

class CBox extends BasicCPCLArg<CBox> {
late int _lineWidth; //边框线条宽度
late int _topLeftX; //矩形框左上角x坐标
late int _topLeftY; //矩形框左上角y坐标
late int _bottomRightX; //矩形框右下角x坐标
late int _bottomRightY; //矩形框右下角y坐标
CBox({
required int lineWidth,
required int topLeftX,
required int topLeftY,
required int bottomRightX,
required int bottomRightY,
}) {
String header() {
cfeed.dart — ! 0 200 200 0 1

完整参数、默认值与命令编码

class CFeed extends BasicCPCLArg<CFeed> {
String header() {
cform.dart — FORM

完整参数、默认值与命令编码

class CForm extends OnlyTextHeaderArg<CForm> {
cgap.dart — GAP-SENSE

完整参数、默认值与命令编码

class CGap extends OnlyTextHeaderArg<CGap> {
String header() {
cimage.dart — ZG / CG

完整参数、默认值与命令编码

class CImage extends BasicCPCLArg<CImage> {
late int _startX;
late int _startY;
late List<int> _image;
late int? _threshold;
late bool _compress;
late bool _reverse;
late int _smoothWeight;
late ThresholdEdgeDitherMode? _edgeDitherMode;
late ThresholdEdgeDitherDepth _edgeDitherDepth;
CImage({
required int startX,
required int startY,
required List<int> image,
bool compress = false,
bool reverse = false,
int? threshold,
int smoothWeight = 0,
ThresholdEdgeDitherMode? edgeDitherMode,
ThresholdEdgeDitherDepth edgeDitherDepth = ThresholdEdgeDitherDepth.shallow,
}) {
String header() {
cinverse.dart — INVERSE-LINE

完整参数、默认值与命令编码

class CInverse extends BasicCPCLArg<CInverse> {
late int _x;
late int _y;
late CFont _font;
late String _content; //打印的文本内容
late CRotation _rotation;
CInverse({
required int x,
required int y,
CFont font = CFont.tss16,
required String content,
CRotation rotation = CRotation.rotation_0,
}) {
String header() {
cline.dart — L / LP

完整参数、默认值与命令编码

class CLine extends BasicCPCLArg<CLine> {
late int _lineWidth; //线条宽度
late int _startX; //左上角x坐标
late int _startY; //左上角y坐标
late int _endX; //右下角x坐标
late int _endY; //右下角y坐标
late bool _isSolidLine = true; //实线:true 虚线:false
CLine({
required int lineWidth,
required int startX,
required int startY,
required int endX,
required int endY,
bool isSolidLine = true,
}) {
String header() {
cmag.dart — SETMAG

完整参数、默认值与命令编码

class CMag extends BasicCPCLArg<CMag> {
late CFont _font;
CMag({
CFont font = CFont.tss16,
}) {
String header() {
cmodel.dart — 10 FF EF F0

完整参数、默认值与命令编码

class CModel extends OnlyBinaryHeaderArg<CModel> {
bool newline() {
cpage.dart

完整参数、默认值与命令编码

class CPage extends BasicCPCLArg<CPage> {
late int _height; //打印区域高度
late int _width; //打印区域宽度
late int _copies; //打印几份
CPage({
required int height,
required int width,
int copies = 1,
}) {
String header() {
cpageheight.dart — ! 0 200 200

完整参数、默认值与命令编码

class CPageHeight extends BasicCPCLArg<CPageHeight> {
late int _pageHeight; //打印区域高度
late int _copies; //打印几份
CPageHeight({
required int pageHeight,
int copies = 1,
}) {
String header() {
cpagemode.dart

完整参数、默认值与命令编码

class CPageMode extends BasicCPCLArg<CPageMode> {
late Location _location;
CPageMode({
Location location = Location.noLocation,
}) {
String header() {
enum Location {
int getLocation() {
cpagewidth.dart — PAGE-WIDTH

完整参数、默认值与命令编码

class CPageWidth extends BasicCPCLArg<CPageWidth> {
late int _pageWidth; //打印区域宽度
CPageWidth({
required int pageWidth,
}) {
String header() {
cprint.dart — POPRINT / PRINT

完整参数、默认值与命令编码

class CPrint extends OnlyTextHeaderArg<CPrint> {
late Mode _mode;
CPrint({
Mode mode = Mode.normal,
}) {
String header() {
enum Mode {
int getMode() {
cqrcode.dart — SETQRVER

完整参数、默认值与命令编码

class CQRCode extends BasicCPCLArg<CQRCode> {
late int _x; //一维码起始横坐标
late int _y; //一维码起始纵坐标
late String _content; //条码内容
late CCodeRotation _codeRotation; //旋转
late int _width; //条码宽度(2-20)
late CCorrectLevel _level; // QrCode纠错等级
CQRCode({
required int x,
required int y,
required String content,
CCodeRotation codeRotation = CCodeRotation.rotation_0,
required int width,
CCorrectLevel? correctLevel = CCorrectLevel.l,
}) {
String header() {
csn.dart — 10 FF EF F2

完整参数、默认值与命令编码

class CSN extends OnlyBinaryHeaderArg<CSN> {
bool newline() {
cstatus.dart — 10 04 05

完整参数、默认值与命令编码

class CStatus extends OnlyBinaryHeaderArg<CStatus> {
bool newline() {
ctext.dart — T${_rotation.getRotation()}

完整参数、默认值与命令编码

class CText extends BasicCPCLArg<CText> {
late CFont _font;
late CRotation _rotation;
late int _textX; //矩形框左上角x坐标
late int _textY; //矩形框左上角y坐标
late String _content; //打印的文本内容
late bool? _bold; //是否加粗
late bool? _underline; //是否下划线
late bool? _mag; //是否字体倍数放大
CText({
CFont font = CFont.tss16,
CRotation rotation = CRotation.rotation_0,
required int textX,
required int textY,
required String content,
bool? bold,
bool? underline,
bool? mag,
}) {
String header() {
ctextcanvas.dart

完整参数、默认值与命令编码

class CTextCanvas extends CText {
final List<int> imageBytes;
final bool compress;
CTextCanvas({
required this.imageBytes,
required int textX,
required int textY,
this.compress = false,
}) : super(
font: CFont.tss16,
rotation: CRotation.rotation_0,
textX: textX,
textY: textY,
content: "",
bold: null,
underline: null,
mag: null,
);
String header() {
final adjustedAlpha = alpha.clamp(0, 255);
final TextStyle textStyle = await _loadTextStyle(font, bold, adjustedAlpha, familyBytes);
final TextPainter textPainter = TextPainter(
text: TextSpan(text: content, style: textStyle),
textDirection: TextDirection.ltr,
)
..layout();
late int canvasWidth;
late int canvasHeight;
const int padding = 2;
final ui.Image textImage = await _drawText(textPainter, canvasWidth, canvasHeight, rotation, padding);
final ui.Image finalImage = adjustedAlpha < 255 ? await _ditheredImage(textImage) : textImage;
final ByteData? pngData = await finalImage.toByteData(format: ui.ImageByteFormat.png);
final imageBytes = pngData.buffer.asUint8List().toList();
final double fontSize = cpclFont.getHeight().toDouble();
final FontWeight fontWeight = isBold == true ? FontWeight.bold : FontWeight.normal;
final ui.PictureRecorder recorder = ui.PictureRecorder();
final Canvas canvas = Canvas(recorder);
final ui.Picture picture = recorder.endRecording();
final int width = image.width;
final int height = image.height;
final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.rawRgba);
final Uint8List rgba = byteData.buffer.asUint8List();
final Float32List grayBuffer = Float32List(width * height);
final int idx = i * 4;
const List<List<int>> matrix = [
final int idx = y * width + x;
final double old = grayBuffer[idx];
final double newVal = old < 128 ? 0.0 : 255.0;
final double error = old - newVal;
final int nx = x + dx;
final int ny = y + dy;
final int matrixX = dx + 2;
final int weight = matrix[dy][matrixX];
final Uint8List result = Uint8List(rgba.length);
final int idx = i * 4;
final int gray = grayBuffer[i].round().clamp(0, 255);
final Completer<ui.Image> completer = Completer<ui.Image>();
cunderline.dart — UNDERLINE

完整参数、默认值与命令编码

class CUnderLine extends BasicCPCLArg<CUnderLine> {
late bool _underline;
CUnderLine({
required bool underline,
}) {
String header() {
cversion.dart — 10 FF EF F1

完整参数、默认值与命令编码

class CVersion extends OnlyBinaryHeaderArg<CVersion> {
bool newline() {
cwatermark.dart — WAT

完整参数、默认值与命令编码

class CWaterMark extends BasicCPCLArg<CWaterMark> {
late int _value;
CWaterMark({
required int value,
}) {
String header() {
ccoderotation.dart

完整参数、默认值与命令编码

enum CCodeRotation {
String getHeader(){
ccodetype.dart

完整参数、默认值与命令编码

enum CCodeType {
String getType(){
ccorrectlevel.dart

完整参数、默认值与命令编码

enum CCorrectLevel {
String getLevel() {
int getLevelInt() {
cfont.dart

完整参数、默认值与命令编码

enum CFont {
int getEx() {
int getEy() {
int getFamily() {
int getSize() {
int getHeight() {
crotation.dart

完整参数、默认值与命令编码

enum CRotation {
String getRotation() {
advanced.go

完整参数、默认值与命令编码

type LocationMode int
const (
type CPageMode struct {
BaseCPCLArg
Location LocationMode // 位置模式
}
func NewCPageMode() *CPageMode {
func (c *CPageMode) SetLocation(location LocationMode) *CPageMode {
func (c *CPageMode) Header() string {
func (c *CPageMode) Clause() *command.Clause {
type CWaterMark struct {
BaseCPCLArg
Type int // 水印类型 (0就正常 打印没水印)
Value int // 水印浓度值(0-255)
}
func NewCWaterMark() *CWaterMark {
func (c *CWaterMark) SetType(t int) *CWaterMark {
func (c *CWaterMark) SetValue(value int) *CWaterMark {
func (c *CWaterMark) Header() string {
func (c *CWaterMark) Clause() *command.Clause {
barcode.go

完整参数、默认值与命令编码

type CBar struct {
BaseCPCLArg
X int // 条码起始x坐标
Y int // 条码起始y坐标
Content string // 条码内容
LineWidth int // 条码线宽度
Height int // 条码高度
CodeType types.CodeType // 条码类型(默认CODE128)
CodeRotation types.CodeRotation // 条码旋转角度(默认不旋转)
}
func NewCBar() *CBar {
func (c *CBar) SetPosition(x, y int) *CBar {
func (c *CBar) SetContent(content string) *CBar {
func (c *CBar) SetLineWidth(width int) *CBar {
func (c *CBar) SetHeight(height int) *CBar {
func (c *CBar) SetCodeType(codeType types.CodeType) *CBar {
func (c *CBar) SetCodeRotation(rotation types.CodeRotation) *CBar {
func (c *CBar) Header() string {
func (c *CBar) Clause() *command.Clause {
box.go — BOX

完整参数、默认值与命令编码

type CBox struct {
BaseCPCLArg
LineWidth int // 矩形框框线条宽度
TopLeftX int // 矩形框左上角x坐标
TopLeftY int // 矩形框左上角y坐标
BottomRightX int // 矩形框右下角x坐标
BottomRightY int // 矩形框右下角y坐标
}
func NewCBox() *CBox {
func (c *CBox) SetLineWidth(width int) *CBox {
func (c *CBox) SetTopLeft(x, y int) *CBox {
func (c *CBox) SetBottomRight(x, y int) *CBox {
func (c *CBox) SetRect(x1, y1, x2, y2 int) *CBox {
func (c *CBox) Header() string {
func (c *CBox) Clause() *command.Clause {
image.go — ZG / CG

完整参数、默认值与命令编码

type CImage struct {
BaseCPCLArg
StartX int // 图片起始x坐标
StartY int // 图片起始y坐标
Image []byte // 图片数据 (已处理的位图数据)
Width int // 图片宽度(像素)
Height int // 图片高度(像素)
GrayThreshold int // 二值化阈值0-255(默认190)
Compress bool // 图片是否压缩(默认不压缩)
Reverse bool // 图片是否反色(默认不反色)
}
func NewCImage() *CImage {
func (c *CImage) SetPosition(x, y int) *CImage {
func (c *CImage) SetImage(data []byte, width, height int) *CImage {
func (c *CImage) SetGrayThreshold(threshold int) *CImage {
func (c *CImage) SetCompress(compress bool) *CImage {
func (c *CImage) SetReverse(reverse bool) *CImage {
func (c *CImage) Header() string {
func (c *CImage) Clause() *command.Clause {
inverse.go — INVERSE-LINE

完整参数、默认值与命令编码

type CInverse struct {
BaseCPCLArg
X int // 文字反色起始x坐标
Y int // 文字反色起始y坐标
Font types.Font // 反色文字字体
Content string // 文本内容
Rotation types.Rotation // 旋转角度(默认不旋转)
}
func NewCInverse() *CInverse {
func (c *CInverse) SetPosition(x, y int) *CInverse {
func (c *CInverse) SetFont(font types.Font) *CInverse {
func (c *CInverse) SetContent(content string) *CInverse {
func (c *CInverse) SetRotation(rotation types.Rotation) *CInverse {
func (c *CInverse) Header() string {
func (c *CInverse) Clause() *command.Clause {
layout.go — ! 0 200 200 0 1

完整参数、默认值与命令编码

type CFeed struct {
BaseCPCLArg
}
func NewCFeed() *CFeed {
func (c *CFeed) Header() string {
func (c *CFeed) Clause() *command.Clause {
type CForm struct {
BaseCPCLArg
}
func NewCForm() *CForm {
func (c *CForm) Header() string {
func (c *CForm) Clause() *command.Clause {
type CGap struct {
BaseCPCLArg
}
func NewCGap() *CGap {
func (c *CGap) Header() string {
func (c *CGap) Clause() *command.Clause {
line.go — L / LP

完整参数、默认值与命令编码

type CLine struct {
BaseCPCLArg
LineWidth int // 线条宽度
StartX int // 线条左上角x坐标
StartY int // 线条左上角y坐标
EndX int // 线条右下角x坐标
EndY int // 线条右下角y坐标
IsSolidLine bool // 实线:true 虚线:false(默认实线)
}
func NewCLine() *CLine {
func (c *CLine) SetLineWidth(width int) *CLine {
func (c *CLine) SetStartPosition(x, y int) *CLine {
func (c *CLine) SetEndPosition(x, y int) *CLine {
func (c *CLine) SetSolidLine(solid bool) *CLine {
func (c *CLine) Header() string {
func (c *CLine) Clause() *command.Clause {
page.go

完整参数、默认值与命令编码

type CPage struct {
BaseCPCLArg
Height int // 打印区域高度(单位dot)
Width int // 打印区域宽度(单位dot)
Copies int // 打印份数(默认一份)
}
func NewCPage() *CPage {
func (c *CPage) SetHeight(height int) *CPage {
func (c *CPage) SetWidth(width int) *CPage {
func (c *CPage) SetCopies(copies int) *CPage {
func (c *CPage) SetSize(width, height int) *CPage {
func (c *CPage) Header() string {
func (c *CPage) Clause() *command.Clause {
type CPageHeight struct {
BaseCPCLArg
PageHeight int // 打印区域高度
Num int // 打印份数(默认一份)
}
func NewCPageHeight() *CPageHeight {
func (c *CPageHeight) SetPageHeight(height int) *CPageHeight {
func (c *CPageHeight) SetNum(num int) *CPageHeight {
func (c *CPageHeight) Header() string {
func (c *CPageHeight) Clause() *command.Clause {
type CPageWidth struct {
BaseCPCLArg
PageWidth int // 打印区域宽度(单位dot)
}
func NewCPageWidth() *CPageWidth {
func (c *CPageWidth) SetPageWidth(width int) *CPageWidth {
func (c *CPageWidth) Header() string {
func (c *CPageWidth) Clause() *command.Clause {
print.go

完整参数、默认值与命令编码

type CPrint struct {
BaseCPCLArg
Mode types.PrintMode // 打印模式(默认正常打印)
}
func NewCPrint() *CPrint {
func (c *CPrint) SetMode(mode types.PrintMode) *CPrint {
func (c *CPrint) Header() string {
func (c *CPrint) Clause() *command.Clause {
qrcode.go — SETQRVER

完整参数、默认值与命令编码

type CQRCode struct {
BaseCPCLArg
X int // 二维码起始x坐标
Y int // 二维码起始y坐标
Content string // 二维码内容
CodeRotation types.CodeRotation // 二维码旋转角度(默认不旋转)
Width int // 二维码小黑点宽度(2-20)
Level types.CorrectLevel // 二维码纠错等级(默认L)
Charset string // 二维码内容编码(默认GBK)
}
func NewCQRCode() *CQRCode {
func (c *CQRCode) SetPosition(x, y int) *CQRCode {
func (c *CQRCode) SetContent(content string) *CQRCode {
func (c *CQRCode) SetCodeRotation(rotation types.CodeRotation) *CQRCode {
func (c *CQRCode) SetWidth(width int) *CQRCode {
func (c *CQRCode) SetCorrectLevel(level types.CorrectLevel) *CQRCode {
func (c *CQRCode) SetCharset(charset string) *CQRCode {
func (c *CQRCode) Header() string {
func (c *CQRCode) Clause() *command.Clause {
status.go

完整参数、默认值与命令编码

type CStatus struct {
BaseCPCLArg
}
func NewCStatus() *CStatus {
func (c *CStatus) Header() string {
func (c *CStatus) Clause() *command.Clause {
func (c *CStatus) Newline() bool {
type CSN struct {
BaseCPCLArg
}
func NewCSN() *CSN {
func (c *CSN) Header() string {
func (c *CSN) Clause() *command.Clause {
type CVersion struct {
BaseCPCLArg
}
func NewCVersion() *CVersion {
func (c *CVersion) Header() string {
func (c *CVersion) Clause() *command.Clause {
type CBatteryVolume struct {
BaseCPCLArg
}
func NewCBatteryVolume() *CBatteryVolume {
func (c *CBatteryVolume) Header() string {
func (c *CBatteryVolume) Clause() *command.Clause {
type CModel struct {
BaseCPCLArg
}
func NewCModel() *CModel {
func (c *CModel) Header() string {
func (c *CModel) Clause() *command.Clause {
style.go — SETBOLD

完整参数、默认值与命令编码

type CBold struct {
BaseCPCLArg
Bold bool // 是否加粗
}
func NewCBold() *CBold {
func (c *CBold) SetBold(bold bool) *CBold {
func (c *CBold) Header() string {
func (c *CBold) Clause() *command.Clause {
type CUnderline struct {
BaseCPCLArg
Underline bool // 是否下划线
}
func NewCUnderline() *CUnderline {
func (c *CUnderline) SetUnderline(underline bool) *CUnderline {
func (c *CUnderline) Header() string {
func (c *CUnderline) Clause() *command.Clause {
type CMag struct {
BaseCPCLArg
Font types.Font // 字体
}
func NewCMag() *CMag {
func (c *CMag) SetFont(font types.Font) *CMag {
func (c *CMag) Header() string {
func (c *CMag) Clause() *command.Clause {
text.go — T

完整参数、默认值与命令编码

type CText struct {
BaseCPCLArg
Font types.Font // 文字字体(默认TSS16)
Rotation types.Rotation // 文字旋转角度(默认不旋转)
TextX int // 文字起始x坐标
TextY int // 文字起始y坐标
Content string // 打印的文本内容
Bold *bool // 是否加粗(默认不加粗)
Underline *bool // 是否加下划线(默认不加下划线)
Mag *bool // 是否字体倍数放大(默认不放大)
Charset string // 文本内容编码(默认GBK)
}
func NewCText() *CText {
func (c *CText) SetFont(font types.Font) *CText {
func (c *CText) SetRotation(rotation types.Rotation) *CText {
func (c *CText) SetPosition(x, y int) *CText {
func (c *CText) SetContent(content string) *CText {
func (c *CText) SetBold(bold bool) *CText {
func (c *CText) SetUnderline(underline bool) *CText {
func (c *CText) SetMag(mag bool) *CText {
func (c *CText) SetCharset(charset string) *CText {
func (c *CText) Header() string {
func (c *CText) Clause() *command.Clause {
font.go

完整参数、默认值与命令编码

type Font struct {
Ex int // 水平放大倍数
Ey int // 垂直放大倍数
Family int // 字体族
Size int // 字体大小
Height int // 字体高度
}
printer_type.go

完整参数、默认值与命令编码

type CPCLPrinter int
const (
func (p CPCLPrinter) String() string {
rotation.go

完整参数、默认值与命令编码

type Rotation string
const (
type CodeRotation string
const (
type CodeType string
const (
func (c CodeType) String() string {
type CorrectLevel string
const (
func (c CorrectLevel) String() string {
func (c CorrectLevel) LevelNum() int {
type PrintMode int
const (
func (p PrintMode) String() string {
CBar.java

完整参数、默认值与命令编码

public class CBar extends BasicCPCLArg<CBar> {
private int x;
private int y;
private String content;
private int lineWidth;
private int height;
private CodeType codeType = CodeType.CODE128;
private CodeRotation codeRotation = CodeRotation.ROTATION_0;//旋转
public String header() {
public CommandClause clause() {
CBatteryVolume.java — 10 FF EF F3

完整参数、默认值与命令编码

public class CBatteryVolume extends OnlyBinaryHeaderArg<CBatteryVolume> {
public byte[] header() {
CBold.java — SETBOLD

完整参数、默认值与命令编码

public class CBold extends BasicCPCLArg<CBold> {
private boolean bold;
public String header() {
public CommandClause clause() {
CBox.java — BOX

完整参数、默认值与命令编码

public class CBox extends BasicCPCLArg<CBox> {
private int lineWidth;
private int topLeftX;
private int topLeftY;
private int bottomRightX;
private int bottomRightY;
public String header() {
public CommandClause clause() {
CFeed.java — ! 0 200 200 0 1

完整参数、默认值与命令编码

public class CFeed extends BasicCPCLArg<CFeed> {
public String header() {
public CommandClause clause() {
CForm.java — FORM

完整参数、默认值与命令编码

public class CForm extends OnlyTextHeaderArg<CForm> {
public String header() {
CGap.java — GAP-SENSE

完整参数、默认值与命令编码

public class CGap extends OnlyTextHeaderArg<CGap> {
public String header() {
CImage.java — ZG / CG

完整参数、默认值与命令编码

public class CImage<T extends ISourceImage> extends BasicCPCLArg<CImage<T>> {
private int startX;
private int startY;
private T image;
private int grayThreshold = 190;
private boolean compress;
private boolean reverse;
public String header() {
public CommandClause clause() {
CInverse.java — INVERSE-LINE

完整参数、默认值与命令编码

public class CInverse extends BasicCPCLArg<CInverse> {
private int x;
private int y;
private Font font = Font.TSS16;
private String content;
private Rotation rotation = Rotation.ROTATION_0;
public String header() {
public CommandClause clause() {
CLine.java — L / LP

完整参数、默认值与命令编码

public class CLine extends BasicCPCLArg<CLine> implements BasicLineArg<String> {
private int lineWidth;//线条宽度
private int startX;//左上角x坐标
private int startY;//左上角y坐标
private int endX;//右下角x坐标
private int endY;//右下角y坐标
private boolean isSolidLine = true;//实线:true 虚线:false
public String header() {
public CommandClause clause() {
CMag.java — SETMAG

完整参数、默认值与命令编码

public class CMag extends BasicCPCLArg<CMag> {
private Font font = Font.TSS16;
public String header() {
public CommandClause clause() {
CModel.java — 10 FF EF F0

完整参数、默认值与命令编码

public class CModel extends OnlyBinaryHeaderArg<CModel> {
public byte[] header() {
CPage.java

完整参数、默认值与命令编码

public class CPage extends BasicCPCLArg<CPage> {
private int height;
private int width;
private int copies = 1;
public String header() {
public CommandClause clause() {
CPageHeight.java — ! 0 200 200

完整参数、默认值与命令编码

public class CPageHeight extends BasicCPCLArg<CPageHeight> {
private int pageHeight;
private int num = 1;
public String header() {
public CommandClause clause() {
CPageMode.java

完整参数、默认值与命令编码

public class CPageMode extends BasicCPCLArg<CPageMode> {
private Location location = Location.NO_LOCATION;
public enum Location {
private final int location;
public int getLocation() {
public String header() {
public CommandClause clause() {
CPageWidth.java — PAGE-WIDTH

完整参数、默认值与命令编码

public class CPageWidth extends BasicCPCLArg<CPageWidth> {
private int pageWidth;
public String header() {
public CommandClause clause() {
CPrint.java — PRINT / ZVPRINT / POPRINT

完整参数、默认值与命令编码

public class CPrint extends OnlyTextHeaderArg<CPrint> {
public enum Mode {
private final int mode;
public int getMode() {
private Mode mode = Mode.NORMAL;
public String header() {
CQRCode.java — SETQRVER

完整参数、默认值与命令编码

public class CQRCode extends BasicCPCLArg<CQRCode> {
private int x;
private int y;
private String content;
private CodeRotation codeRotation = CodeRotation.ROTATION_0;
private int width;
private CorrectLevel level = CorrectLevel.L;
public String header() {
public CommandClause clause() {
CSN.java — 10 FF EF F2

完整参数、默认值与命令编码

public class CSN extends OnlyBinaryHeaderArg<CSN> {
public byte[] header() {
CStatus.java — 10 04 05

完整参数、默认值与命令编码

public class CStatus extends OnlyBinaryHeaderArg<CStatus> {
public byte[] header() {
public boolean newline() {
CText.java — T

完整参数、默认值与命令编码

public class CText extends BasicCPCLArg<CText> {
private Font font = Font.TSS16;
private Rotation rotation = Rotation.ROTATION_0;
private int textX;
private int textY;
private String content;
private Boolean bold;
private Boolean underline;
private Boolean mag;
public String header() {
public CommandClause clause() {
CUnderLine.java — UNDERLINE

完整参数、默认值与命令编码

public class CUnderLine extends BasicCPCLArg<CUnderLine> {
private boolean underline;
public String header() {
public CommandClause clause() {
CVersion.java — 10 FF EF F1

完整参数、默认值与命令编码

public class CVersion extends OnlyBinaryHeaderArg<CVersion> {
public byte[] header() {
CWaterMark.java — WAT

完整参数、默认值与命令编码

public class CWaterMark extends BasicCPCLArg<CWaterMark> {
private int type = 9;
private int value = 0;
public String header() {
public CommandClause clause() {
CodeRotation.java

完整参数、默认值与命令编码

public enum CodeRotation {
private final String rotation;
public String getRotation() {
CodeType.java

完整参数、默认值与命令编码

public enum CodeType {
private final String type;
private final int width;
public String getType() {
public int getWidth() {
CorrectLevel.java

完整参数、默认值与命令编码

public enum CorrectLevel {
private final String level;
private final int levelNum;
public String getLevel() {
public int getLevelNum() {
Font.java

完整参数、默认值与命令编码

public enum Font {
private final int ex;
private final int ey;
private final int family;
private final int size;
private final int height;
public int getEx() {
public int getEy() {
public int getFamily() {
public int getSize() {
public int getHeight() {
Rotation.java

完整参数、默认值与命令编码

public enum Rotation {
private final String rotation;
public String getRotation() {
bar.ts

完整参数、默认值与命令编码

export class CBar extends BasicCPCLArg<CBar> {
private x: number;
private y: number;
private content: string;
private lineWidth: number;
private height: number;
private codeRotation: CCodeRotation;
private codeType: CCodeType;
constructor(options?: {
x?: number
y?: number
content?: string
lineWidth?: number
height?: number
codeType?: CCodeType
codeRotation?: CCodeRotation
}) {
class CodeTypeEntity {
constructor(type, width) {
bold.ts — SETBOLD

完整参数、默认值与命令编码

export class CBold extends BasicCPCLArg<CBold> {
private bold: boolean;
constructor(options?: {
bold?: boolean
}) {
box.ts — BOX

完整参数、默认值与命令编码

export class CBox extends BasicCPCLArg<CBox> {
private lineWidth: number;
private topLeftX: number;
private topLeftY: number;
private bottomRightX: number;
private bottomRightY: number;
constructor(options?: {
lineWidth?: number
topLeftX?: number
topLeftY?: number
bottomRightX?: number
bottomRightY?: number
}) {
feed.ts — ! 0 200 200 0 1

完整参数、默认值与命令编码

export class CFeed extends BasicCPCLArg<CFeed> {
form.ts — FORM

完整参数、默认值与命令编码

export class CForm extends OnlyTextHeaderArg<CForm> {
gap.ts — GAP-SENSE

完整参数、默认值与命令编码

export class CGap extends OnlyTextHeaderArg<CGap> {
image.ts — ZG / CG

完整参数、默认值与命令编码

export class CImage extends BasicCPCLArg<CImage> {
private x: number;
private y: number;
private readonly compress: boolean;
private readonly image: InputImage;
private readonly reverse: boolean;
private readonly threshold: number;
constructor(options: {
x?: number,
y?: number,
compress?: boolean,
reverse?: boolean,
threshold?: number,
image: InputImage,
}) {
const processer = new Pbita({
command:'cpcl',
threshold: this.threshold,
compress: this.compress,
reverse: this.reverse,
}
);
const info = processer.process(this.image);
const fimage = info.result.data;
const fbytes = info.result.bytes;
const eWidth = Math.floor((width % 8 === 0) ? (width / 8) : (width / 8 + 1));
const command = Commander.make().pushClause(CPCLCommand.with(this.header())
.appendNumber(eWidth)
.appendNumber(height)
.appendNumber(this.compress ? this.x / 8 : this.x)
.appendNumber(this.y)
.appendNumber(this.compress ? fbytes.length : null)
.clause(), false)
.pushText(" ", {newline: false})
.pushBinary(fbytes, false)
.newline()
.command();
inverse.ts — INVERSE-LINE

完整参数、默认值与命令编码

export class CInverse extends BasicCPCLArg<CInverse> {
private x: number;
private y: number;
private width: number;
private height: number;
constructor(options?: {
x?: number
y?: number
width?: number
height?: number
}) {
line.ts — LINE / LPLINE

完整参数、默认值与命令编码

export class CLine extends BasicCPCLArg<CLine> {
private width: number;
private startX: number;
private startY: number;
private endX: number;
private endY: number;
private isSolidLine: boolean;
constructor(options?: {
width?: number
startX?: number
startY?: number
endX?: number
endY?: number
isSolidLine?: boolean
}) {
mag.ts — SETMAG

完整参数、默认值与命令编码

export class CMag extends BasicCPCLArg<CMag> {
private font: CFont;
constructor(options?: {
font?: CFont
}) {
class FontEntity {
constructor(ex, ey, family, size, height) {
page.ts

完整参数、默认值与命令编码

export class CPage extends BasicCPCLArg<CPage> {
private readonly width: number;
private readonly height: number;
private readonly copies: number;
constructor(options?: {
width?: number,
height?: number
copies?: number
}) {
pageheight.ts — ! 0 200 200

完整参数、默认值与命令编码

export class CPageHeight extends BasicCPCLArg<CPageHeight> {
private height: number;
private copies: number;
constructor(options?: {
height?: number
copies?: number
}) {
pagemode.ts

完整参数、默认值与命令编码

export class CPageMode extends BasicCPCLArg<CPageMode> {
private location: CLocation;
constructor(options?: {
location?: CLocation
}) {
pagesetup.ts

完整参数、默认值与命令编码

export class CPageSetup extends BasicCPCLArg<CPageSetup> {
private pageHeight: number;
private pageWidth: number;
constructor(options?: {
pageHeight?: number
pageWidth?: number
}) {
pagewidth.ts — PAGE-WIDTH

完整参数、默认值与命令编码

export class CPageWidth extends BasicCPCLArg<CPageWidth> {
private width: number;
constructor(options?: {
width?: number
}) {
print.ts — POPRINT / PRINT

完整参数、默认值与命令编码

export class CPrint extends OnlyTextHeaderArg<CPrint> {
private readonly mode: CMode;
constructor(options?: {
mode?: CMode
}) {
qrcode.ts — SETQRVER

完整参数、默认值与命令编码

export class CQRCode extends BasicCPCLArg<CQRCode> {
private x: number;
private y: number;
private content: string;
private codeRotation: CCodeRotation;
private level: CCorrectLevel;
private charset: string;
constructor(options: {
x?: number
y?: number
content?: string
codeRotation?: CCodeRotation
width?: number
level?: CCorrectLevel
charset?: string
}) {
sn.ts — 10 FF EF F2

完整参数、默认值与命令编码

export class CSN extends OnlyBinaryHeaderArg<CSN> {
constructor() {
status.ts — 10 04 05

完整参数、默认值与命令编码

export class CStatus extends OnlyBinaryHeaderArg<CStatus> {
constructor() {
text.ts — T

完整参数、默认值与命令编码

export class CText extends BasicCPCLArg<CText> {
public x: number;
public y: number;
private content: string;
private readonly font: CFont;
private rotation: CRotation;
private charset: string;
constructor(options?: {
x?: number
y?: number
content?: string
font?: CFont
rotation?: CRotation
charset?: string
}) {
class FontEntity {
constructor(ex, ey, family, size, height) {
textcanvas.ts

完整参数、默认值与命令编码

export class CTextCanvas extends CText {
private readonly inputImage: InputImage;
private readonly compress: boolean;
constructor(options: {
x: number;
y: number;
inputImage: InputImage;
compress?: boolean;
}) {
const cImage = new CImage({
x: this.x,
y: this.y,
image: this.inputImage,
compress: this.compress,
});
const canvasMaxW = maxWidth; // 画布最大宽(需匹配页面 <canvas> 元素尺寸,可传入更大值避免文字被截断)
const canvasMaxH = maxHeight; // 画布最大高
const uniAPI: any = typeof uni !== "undefined" ? uni : (globalThis as any).uni;
if (!uniAPI) {
const ctx = uniAPI.createCanvasContext(canvasId, component);
const metrics = ctx.measureText(content);
const canvasW = Math.min(Math.ceil(textWidth) + padding * 2, canvasMaxW);
const canvasH = Math.min(Math.ceil(fontSize * 1.2) + padding * 2, canvasMaxH);
underline.ts — UNDERLINE

完整参数、默认值与命令编码

export class CUnderLine extends BasicCPCLArg<CUnderLine> {
private underline: boolean;
constructor(options?: {
underline?: boolean
}) {
watermark.ts — WAT

完整参数、默认值与命令编码

export class CWaterMark extends BasicCPCLArg<CWaterMark> {
private value: number;
constructor(options?: {
value?: number
}) {
coderotation.ts

完整参数、默认值与命令编码

export enum CCodeRotation {
codetype.ts

完整参数、默认值与命令编码

export enum CCodeType {
correctlevel.ts

完整参数、默认值与命令编码

export enum CCorrectLevel {
font.ts

完整参数、默认值与命令编码

export enum CFont {
index.ts

完整参数、默认值与命令编码

location.ts

完整参数、默认值与命令编码

export enum CLocation {
mode.ts

完整参数、默认值与命令编码

export enum CMode {
rotation.ts

完整参数、默认值与命令编码

export enum CRotation {
CBar.h

完整参数、默认值与命令编码

@interface CBar : BasicCPCLArg
@property (nonatomic , readonly) CBar *(^x)(int startX);
@property (nonatomic , readonly) CBar *(^y)(int startY);
@property (nonatomic , readonly) CBar *(^content)(NSString *cnt);
@property (nonatomic , readonly) CBar *(^lineWidth)(int width);
@property (nonatomic , readonly) CBar *(^height)(int lineHeight);
@property (nonatomic , readonly) CBar *(^codeType)(CCodeType ct);
@property (nonatomic , readonly) CBar *(^codeRotation)(CCodeRotation cr);
@end
CBar.m

完整参数、默认值与命令编码

@interface CBar()
@property(nonatomic , assign) int startX;
@property(nonatomic , assign) int startY;
@property(nonatomic , strong) NSString * cnt;
@property(nonatomic , assign) int width;
@property(nonatomic , assign) int lineHeight;
@property(nonatomic , strong) CCodeType ct;
@property(nonatomic , strong) CCodeRotation cr;
@end
@end
CBatteryVolume.h

完整参数、默认值与命令编码

@interface CBatteryVolume : OnlyTextHeaderArg
@end
CBatteryVolume.m

完整参数、默认值与命令编码

@end
CBold.h

完整参数、默认值与命令编码

@interface CBold : BasicCPCLArg
@property (nonatomic, readonly) CBold *(^bold)(BOOL isBold);
@end
CBold.m — SETBOLD

完整参数、默认值与命令编码

@interface CBold()
@property(nonatomic , assign) BOOL isBold;
@end
@end
CBox.h

完整参数、默认值与命令编码

@interface CBox : BasicCPCLArg
@property (nonatomic, readonly) CBox *(^width)(int lineWidth);
@property (nonatomic, readonly) CBox *(^topLeftX)(int lineTopLeftX);
@property (nonatomic, readonly) CBox *(^topLeftY)(int lineTopLeftY);
@property (nonatomic, readonly) CBox *(^bottomRightX)(int lineBottomRightX);
@property (nonatomic, readonly) CBox *(^bottomRightY)(int lineBottomRightY);
@end
CBox.m — BOX

完整参数、默认值与命令编码

@interface CBox()
@property(nonatomic , assign) int lineWidth;
@property(nonatomic , assign) int lineTopLeftX;
@property(nonatomic , assign) int lineTopLeftY;
@property(nonatomic , assign) int lineBottomRightX;
@property(nonatomic , assign) int lineBottomRightY;
@end
@end
CFeed.h

完整参数、默认值与命令编码

@interface CFeed : BasicCPCLArg
@end
CFeed.m — ! 0 200 200 0 1

完整参数、默认值与命令编码

@end
CForm.h

完整参数、默认值与命令编码

@interface CForm : OnlyTextHeaderArg
@end
CForm.m — FORM

完整参数、默认值与命令编码

@end
CGap.h

完整参数、默认值与命令编码

@interface CGap : OnlyTextHeaderArg
@end
CGap.m — GAP-SENSE

完整参数、默认值与命令编码

@end
CImage.h

完整参数、默认值与命令编码

@interface CImage : BasicCPCLArg
@property (nonatomic, readonly) CImage *(^startX)(int imageStartX);
@property (nonatomic, readonly) CImage *(^startY)(int imageStartY);
@property (nonatomic, readonly) CImage *(^width)(int imageWidth);
@property (nonatomic, readonly) CImage *(^height)(int imageHeight);
@property (nonatomic, readonly) CImage *(^image)(UIImage * img);
@property (nonatomic, readonly) CImage *(^compress)(BOOL isCompress);
@property (nonatomic, readonly) CImage *(^reverse)(BOOL isReverse);
@end
CImage.m — ZG / CG

完整参数、默认值与命令编码

@interface CImage()
@property(nonatomic , assign) int imageStartX;
@property(nonatomic , assign) int imageStartY;
@property(nonatomic , assign) int imageWidth;
@property(nonatomic , assign) int imageHeight;
@property(nonatomic , strong) UIImage *img ;
@property(nonatomic , assign) BOOL isCompress;
@property(nonatomic , assign) BOOL isReverse;
@end
@end
CInverse.h

完整参数、默认值与命令编码

@interface CInverse : BasicCPCLArg
@property (nonatomic, readonly) CInverse *(^x)(int X);
@property (nonatomic, readonly) CInverse *(^y)(int Y);
@property (nonatomic, readonly) CInverse *(^Fnt)(CFont font);
@property (nonatomic, readonly) CInverse *(^content)(id conten);
@property (nonatomic, readonly) CInverse *(^rotation)(CRotation InRotation);
@end
CInverse.m — INVERSE-LINE

完整参数、默认值与命令编码

@interface CInverse()
@property (nonatomic, assign) int X;
@property (nonatomic, assign) int Y;
@property (nonatomic, strong) CPCLFont* font;
@property (nonatomic, strong) NSString * conten;
@property (nonatomic, assign) CRotation inRotation;
@end
@end
CLine.h

完整参数、默认值与命令编码

@interface CLine : BasicCPCLArg
@property (nonatomic , readonly) CLine *(^lineWidth)(int clineWidth);
@property (nonatomic , readonly) CLine *(^startX)(int cStartX);
@property (nonatomic , readonly) CLine *(^startY)(int cStartY);
@property (nonatomic , readonly) CLine *(^endX)(int cEndX);
@property (nonatomic , readonly) CLine *(^endY)(int cEndY);
@property (nonatomic , readonly) CLine *(^isSolidLine)(BOOL cIsSolidLine);
@end
CLine.m — L / LP

完整参数、默认值与命令编码

@interface CLine()
@property (nonatomic, assign) int cLineWidth;
@property (nonatomic, assign) int cStartX;
@property (nonatomic, assign) int cStartY;
@property (nonatomic, assign) int cEndX;
@property (nonatomic, assign) int cEndY;
@property (nonatomic, assign) BOOL cIsSolidLine;
@end
@end
CMag.h

完整参数、默认值与命令编码

@interface CMag : BasicCPCLArg
@property (nonatomic , readonly) CMag *(^font)(CFont fnt);
@end
CMag.m — SETMAG

完整参数、默认值与命令编码

@interface CMag()
@property (nonatomic , strong) CPCLFont *fnt;
@end
@end
CPage.h

完整参数、默认值与命令编码

@interface CPage : BasicCPCLArg
@property(nonatomic, readonly) CPage *(^height)(int cHeight);
@property(nonatomic, readonly) CPage *(^width)(int cWidth);
@property(nonatomic, readonly) CPage *(^num)(int cNum);
@end
CPage.m

完整参数、默认值与命令编码

@interface CPage()
@property (nonatomic , assign) int cheight;
@property (nonatomic , assign) int cwidth;
@property (nonatomic , assign) int cNum;
@end
@end
CPageHeight.h

完整参数、默认值与命令编码

@interface CPageHeight : BasicCPCLArg
@property (nonatomic , readonly) CPageHeight *(^pageHeight)(int cPageHeight);
@property (nonatomic , readonly) CPageHeight *(^num)(int cNum);
@end
CPageHeight.m — ! 0 200 200

完整参数、默认值与命令编码

@interface CPageHeight()
@property (nonatomic , assign) int cPageHeight;
@property (nonatomic , assign) int cNum;
@end
@end
CPageMode.h

完整参数、默认值与命令编码

@interface CPageMode : BasicCPCLArg
@end
CPageMode.m

完整参数、默认值与命令编码

@end
CPageWidth.h

完整参数、默认值与命令编码

@interface CPageWidth : BasicCPCLArg
@property(nonatomic , readonly) CPageWidth *(^pageWidth)(int cpageWidth);
@end
CPageWidth.m — PAGE-WIDTH

完整参数、默认值与命令编码

@interface CPageWidth()
@property (nonatomic , assign) int cpageWidth;
@end
@end
CPrint.h

完整参数、默认值与命令编码

@interface CPrint : OnlyTextHeaderArg
@property (nonatomic , readonly) CPrint *(^mode)(Mode m);
-(int)getMode;
@end
CPrint.m — POPRINT / PRINT

完整参数、默认值与命令编码

@interface CPrint()
@property (nonatomic , assign) Mode m;
@end
@end
CQRCode.h

完整参数、默认值与命令编码

@interface CQRCode : BasicCPCLArg
@property (nonatomic , readonly) CQRCode *(^x)(int cx);
@property (nonatomic , readonly) CQRCode *(^y)(int cy);
@property (nonatomic , readonly) CQRCode *(^content)(id ccontent);
@property (nonatomic , readonly) CQRCode *(^codeRotation)(CCodeRotation ccodeRotation);
@property (nonatomic , readonly) CQRCode *(^width)(int cWidth);
@property (nonatomic , readonly) CQRCode *(^level)(CCorrectLevel cLevel);
@end
CQRCode.m — SETQRVER

完整参数、默认值与命令编码

@interface CQRCode()
@property (nonatomic ,assign) int cx;
@property (nonatomic ,assign) int cy;
@property (nonatomic ,strong) NSString * cContent;
@property (nonatomic ,strong) CPCLCodeRotation * cCodeRotation;
@property (nonatomic ,assign) int cWidth;
@property (nonatomic ,strong) CPCLCorrectLevel* cCorrectLevel;
@end
@end
CStatus.h

完整参数、默认值与命令编码

@interface CStatus : OnlyBinaryHeaderArg
@end
CStatus.m — 10 04 05

完整参数、默认值与命令编码

@end
CText.h

完整参数、默认值与命令编码

@interface CText : BasicCPCLArg
@property (nonatomic , readonly) CText *(^font)(CFont fnt);
@property (nonatomic , readonly) CText *(^rotation)(CRotation rot);
@property (nonatomic , readonly) CText *(^textX)(int text);
@property (nonatomic , readonly) CText *(^textY)(int text);
@property (nonatomic , readonly) CText *(^content)(id text);
@property (nonatomic , readonly) CText *(^bold)(BOOL isBold);
@property (nonatomic , readonly) CText *(^underline)(BOOL isUnderline);
@property (nonatomic , readonly) CText *(^mag)(BOOL isMag);
@end
CText.m — %@%@ / T

完整参数、默认值与命令编码

@interface CText()
@property(nonatomic, strong) CPCLFont *fnt;
@property(nonatomic, strong) CPCLRotation *rot;
@property(nonatomic, assign) int tx;
@property(nonatomic, assign) int ty;
@property(nonatomic, strong) NSString *ct;
@property(nonatomic, assign) BOOL isBold;
@property(nonatomic, assign) BOOL isUnderline;
@property(nonatomic, assign) BOOL isMag;
@end
@end
CUnderLine.h

完整参数、默认值与命令编码

@interface CUnderLine : BasicCPCLArg
@property(nonatomic , readonly) CUnderLine *(^underline)(BOOL isUnderline);
@end
CUnderLine.m — UNDERLINE

完整参数、默认值与命令编码

@interface CUnderLine()
@property (nonatomic , assign) BOOL isUnderline;
@end
@end
CWaterMark.h

完整参数、默认值与命令编码

@interface CWaterMark : BasicCPCLArg
@property(nonatomic , readonly) CWaterMark *(^value)(int val);
@end
CWaterMark.m — WAT

完整参数、默认值与命令编码

@interface CWaterMark()
@property(nonatomic , assign) int val;
@end
@end
CPCLCodeRotation.h

完整参数、默认值与命令编码

@interface CPCLCodeRotation : NSObject
@property (nonatomic , assign)CCodeRotation rotation;
-(NSString *)getRotation;
@end
CPCLCodeRotation.m

完整参数、默认值与命令编码

@end
CPCLCodeType.h

完整参数、默认值与命令编码

@interface CPCLCodeType : NSObject
@property (nonatomic , assign)CCodeType codetype;
-(NSString *)getType;
-(int)getWidth;
@end
CPCLCodeType.m

完整参数、默认值与命令编码

@interface CPCLCodeType()
@property(nonatomic , strong) NSString *type;
@property(nonatomic , assign) int width;
@end
@end
CPCLCorrectLevel.h

完整参数、默认值与命令编码

@interface CPCLCorrectLevel : NSObject
@property(nonatomic , assign)CCorrectLevel level;
-(NSString *)getLevel;
@end
CPCLCorrectLevel.m

完整参数、默认值与命令编码

@end
CPCLFont.h

完整参数、默认值与命令编码

@interface CPCLFont : NSObject
@property(nonatomic , readonly)CPCLFont *(^font)(CFont fnt);
- (int) getEx;
- (int) getEy;
- (int) getFamily;
- (int) getSize;
- (int) getHeight;
@end
CPCLFont.m

完整参数、默认值与命令编码

@interface CPCLFont()
@property (nonatomic , strong)NSString *fnt;
@property (nonatomic , assign)int ex;
@property (nonatomic , assign)int ey;
@property (nonatomic , assign)int family;
@property (nonatomic , assign)int size;
@property (nonatomic , assign)int height;
@end
@end
CPCLRotation.h

完整参数、默认值与命令编码

@interface CPCLRotation : NSObject
@property(nonatomic , readonly) CPCLRotation *(^rotation)(CRotation rot);
-(NSString *)getRotation;
@end
CPCLRotation.m

完整参数、默认值与命令编码

@interface CPCLRotation()
@property(nonatomic , assign) CRotation rot;
@end
@end
bar.rs

完整参数、默认值与命令编码

pub struct CBarOptions {
pub x: i32,
pub y: i32,
pub content: String,
pub line_width: i32,
pub height: i32,
pub code_type: Option<CodeType>,
pub code_rotation: Option<CodeRotation>,
pub struct CBar {
pub fn new(options: CBarOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl<T: Into<String>> From<(i32, i32, T, i32, i32)> for CBar {
fn from((x, y, content, line_width, height): (i32, i32, T, i32, i32)) -> Self {
battery_volume.rs — 10 FF EF F3

完整参数、默认值与命令编码

pub struct CBatteryVolume {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<Vec<u8>> for CBatteryVolume {
fn context(&self) -> Arc<Mutex<ArgContext>> {
bold.rs — SETBOLD

完整参数、默认值与命令编码

pub struct CBoldOptions {
pub enable: bool,
pub struct CBold {
pub fn new(options: CBoldOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<String> for CBold {
fn context(&self) -> Arc<Mutex<ArgContext>> {
box_.rs — BOX

完整参数、默认值与命令编码

pub struct CBoxOptions {
pub line_width: i32,
pub top_left_x: i32,
pub top_left_y: i32,
pub bottom_right_x: i32,
pub bottom_right_y: i32,
pub struct CBox {
pub fn new(options: CBoxOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl From<(i32, i32, i32, i32, i32)> for CBox {
fn from(
(line_width, top_left_x, top_left_y, bottom_right_x, bottom_right_y): (i32, i32, i32, i32, i32),
) -> Self {
feed.rs — ! 0 200 200 0 1

完整参数、默认值与命令编码

pub struct CFeed {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<String> for CFeed {
fn context(&self) -> Arc<Mutex<ArgContext>> {
form.rs — FORM

完整参数、默认值与命令编码

pub struct CForm {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<String> for CForm {
fn context(&self) -> Arc<Mutex<ArgContext>> {
gap.rs — GAP-SENSE

完整参数、默认值与命令编码

pub struct CGap {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<String> for CGap {
fn context(&self) -> Arc<Mutex<ArgContext>> {
image_bytes.rs

完整参数、默认值与命令编码

pub struct CImageBytesOptions {
pub x: i32,
pub y: i32,
pub bytes: Vec<u8>,
pub compress: bool,
pub reverse: bool,
pub gray_threshold: Option<i32>,
pub smooth_weight: i32,
pub edge_dither_mode: Option<ThresholdEdgeDitherMode>,
pub edge_dither_depth: ThresholdEdgeDitherDepth,
pub struct CImageBytes {
pub fn new(options: CImageBytesOptions) -> PsdkFatherResult<Self> {
let pixmap =
Pixmap::decode_png(&options.bytes).map_err(|e| PsdkFatherError::Image(format!("{:?}", e)))?;
let width = pixmap.width();
image_pixels.rs — ZG / CG

完整参数、默认值与命令编码

pub struct CImagePixelsOptions {
pub x: i32,
pub y: i32,
pub pixels: Vec<u8>,
pub width: u32,
pub height: u32,
pub compress: bool,
pub reverse: bool,
pub gray_threshold: Option<i32>,
pub smooth_weight: i32,
pub edge_dither_mode: Option<ThresholdEdgeDitherMode>,
pub edge_dither_depth: ThresholdEdgeDitherDepth,
pub struct CImagePixels {
pub fn new(options: CImagePixelsOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl From<(i32, i32, Vec<u8>, u32, u32)> for CImagePixels {
fn from((x, y, pixels, width, height): (i32, i32, Vec<u8>, u32, u32)) -> Self {
inverse.rs — INVERSE-LINE

完整参数、默认值与命令编码

pub struct CInverseOptions {
pub x: i32,
pub y: i32,
pub font: Option<Font>,
pub content: String,
pub rotation: Option<Rotation>,
pub struct CInverse {
pub fn new(options: CInverseOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl<T: Into<String>> From<(i32, i32, T)> for CInverse {
fn from((x, y, content): (i32, i32, T)) -> Self {
line.rs — L / LP

完整参数、默认值与命令编码

pub struct CLineOptions {
pub line_width: i32,
pub start_x: i32,
pub start_y: i32,
pub end_x: i32,
pub end_y: i32,
pub is_solid_line: bool,
pub struct CLine {
pub fn new(options: CLineOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl From<(i32, i32, i32, i32, i32)> for CLine {
fn from((line_width, start_x, start_y, end_x, end_y): (i32, i32, i32, i32, i32)) -> Self {
mag.rs — SETMAG

完整参数、默认值与命令编码

pub struct CMagOptions {
pub font: Option<Font>,
pub struct CMag {
pub fn new(options: CMagOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl Default for CMag {
fn default() -> Self {
model.rs — 10 FF EF F0

完整参数、默认值与命令编码

pub struct CModel {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<Vec<u8>> for CModel {
fn context(&self) -> Arc<Mutex<ArgContext>> {
page.rs

完整参数、默认值与命令编码

pub struct CPageOptions {
pub height: i32,
pub width: i32,
pub copies: i32,
pub struct CPage {
pub fn new(options: CPageOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl From<(i32, i32)> for CPage {
fn from((height, width): (i32, i32)) -> Self {
page_height.rs — ! 0 200 200

完整参数、默认值与命令编码

pub struct CPageHeightOptions {
pub height: i32,
pub copies: i32,
pub struct CPageHeight {
pub fn new(options: CPageHeightOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl From<i32> for CPageHeight {
fn from(height: i32) -> Self {
page_mode.rs

完整参数、默认值与命令编码

pub enum Location {
pub struct CPageModeOptions {
pub location: Location,
pub struct CPageMode {
pub fn new(options: CPageModeOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl Default for CPageMode {
fn default() -> Self {
page_width.rs — PAGE-WIDTH

完整参数、默认值与命令编码

pub struct CPageWidthOptions {
pub width: i32,
pub struct CPageWidth {
pub fn new(options: CPageWidthOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl From<i32> for CPageWidth {
fn from(width: i32) -> Self {
print.rs — PRINT / POPRINT

完整参数、默认值与命令编码

pub struct CPrintOptions {
pub mode: Option<Mode>,
pub struct CPrint {
pub fn new(options: CPrintOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl Default for CPrint {
fn default() -> Self {
qrcode.rs — SETQRVER

完整参数、默认值与命令编码

pub struct CQRCodeOptions {
pub x: i32,
pub y: i32,
pub content: String,
pub code_rotation: Option<CodeRotation>,
pub width: i32,
pub level: Option<CorrectLevel>,
pub struct CQRCode {
pub fn new(options: CQRCodeOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl<T: Into<String>> From<(i32, i32, T, i32)> for CQRCode {
fn from((x, y, content, width): (i32, i32, T, i32)) -> Self {
sn.rs — 10 FF EF F2

完整参数、默认值与命令编码

pub struct CSN {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<Vec<u8>> for CSN {
fn context(&self) -> Arc<Mutex<ArgContext>> {
status.rs — 10 04 05

完整参数、默认值与命令编码

pub struct CStatus {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<Vec<u8>> for CStatus {
fn context(&self) -> Arc<Mutex<ArgContext>> {
text.rs — T{}

完整参数、默认值与命令编码

pub struct CTextOptions {
pub font: Option<Font>,
pub x: i32,
pub y: i32,
pub content: String,
pub bold: Option<bool>,
pub underline: Option<bool>,
pub mag: Option<bool>,
pub rotation: Option<Rotation>,
pub struct CText {
pub fn new(options: CTextOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl<T: Into<String>> From<(i32, i32, T)> for CText {
fn from((x, y, content): (i32, i32, T)) -> Self {
text_canvas.rs

完整参数、默认值与命令编码

pub struct CTextCanvasOptions {
pub x: i32,
pub y: i32,
pub image_bytes: Vec<u8>,
pub compress: bool,
pub struct CTextCanvasImageOptions {
pub content: String,
pub font: Font,
pub rotation: Rotation,
pub bold: Option<bool>,
pub alpha: i32,
pub struct CTextCanvas {
pub fn new(options: CTextCanvasOptions) -> PsdkFatherResult<Self> {
Ok(Self {
image_bytes: CImageBytes::new(CImageBytesOptions {
x: options.x,
y: options.y,
bytes: options.image_bytes,
compress: options.compress,
reverse: false,
gray_threshold: None,
smooth_weight: 0,
edge_dither_mode: None,
edge_dither_depth: Default::default(),
})?,
})
}
pub fn generate_image_bytes(options: CTextCanvasImageOptions) -> PsdkFatherResult<Vec<u8>> {
let alpha = options.alpha.clamp(0, 255) as u8;
let font_height = options.font.get_height().max(7);
underline.rs — UNDERLINE

完整参数、默认值与命令编码

pub struct CUnderLineOptions {
pub enable: bool,
pub struct CUnderLine {
pub fn new(options: CUnderLineOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<String> for CUnderLine {
fn context(&self) -> Arc<Mutex<ArgContext>> {
version.rs — 10 FF EF F1

完整参数、默认值与命令编码

pub struct CVersion {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<Vec<u8>> for CVersion {
fn context(&self) -> Arc<Mutex<ArgContext>> {
water_mark.rs — WAT

完整参数、默认值与命令编码

pub struct CWaterMarkOptions {
pub mark_type: u32,
pub value: i32,
pub struct CWaterMark {
pub fn new(options: CWaterMarkOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl From<i32> for CWaterMark {
fn from(value: i32) -> Self {
marks.rs

完整参数、默认值与命令编码

pub enum CodeType {
pub fn width(&self) -> u32 {
match self {
CodeType::Code39 => 2,
CodeType::Code128 => 2,
CodeType::Code93 => 1,
CodeType::Codabar => 2,
CodeType::Ean8 => 2,
CodeType::Ean13 => 2,
CodeType::Upca => 2,
CodeType::Upce => 2,
CodeType::I2Of5 | CodeType::I20F5 => 2,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CodeRotation {
pub enum Font {
pub fn get_ex(&self) -> u32 {
match self {
Font::Tss16 | Font::Tss20 | Font::Tss24 | Font::Tss28 | Font::Tss32 => 1,
Font::Tss20Max1 | Font::Tss24Max1 | Font::Tss28Max1 | Font::Tss32Max1 => 2,
Font::Tss24Max2 | Font::Tss28Max2 | Font::Tss32Max2 => 3,
}
}
pub fn get_ey(&self) -> u32 {
match self {
Font::Tss16 | Font::Tss20 | Font::Tss24 | Font::Tss28 | Font::Tss32 => 1,
Font::Tss20Max1 | Font::Tss24Max1 | Font::Tss28Max1 | Font::Tss32Max1 => 2,
Font::Tss24Max2 | Font::Tss28Max2 | Font::Tss32Max2 => 3,
}
}
pub fn get_family(&self) -> u32 {
match self {
Font::Tss16 => 55,
Font::Tss20 | Font::Tss20Max1 => 6,
Font::Tss28 | Font::Tss28Max1 | Font::Tss28Max2 => 7,
Font::Tss24 | Font::Tss24Max1 | Font::Tss24Max2 => 24,
Font::Tss32 | Font::Tss32Max1 | Font::Tss32Max2 => 4,
}
}
pub fn get_size(&self) -> u32 {
match self {
Font::Tss16 | Font::Tss20 | Font::Tss24 | Font::Tss28 | Font::Tss32 => 0,
Font::Tss20Max1
| Font::Tss24Max1
| Font::Tss28Max1
| Font::Tss32Max1
| Font::Tss24Max2
| Font::Tss28Max2
| Font::Tss32Max2 => 0,
}
}
pub fn get_height(&self) -> u32 {
match self {
Font::Tss16 => 16,
Font::Tss20 => 20,
Font::Tss20Max1 => 40,
Font::Tss24 => 24,
Font::Tss28 => 28,
Font::Tss32 => 32,
Font::Tss24Max1 => 48,
Font::Tss28Max1 => 56,
Font::Tss32Max1 => 64,
Font::Tss24Max2 => 72,
Font::Tss28Max2 => 84,
Font::Tss32Max2 => 96,
}
}
}
#[derive(Clone, Debug)]
pub enum Rotation {
pub enum Mode {
pub fn get_mode(&self) -> u32 {
match self {
Mode::Normal => 0,
Mode::Horizontal => 1,
Mode::Mirror => 2,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CorrectLevel {
pub fn get_level(&self) -> String {
match self {
CorrectLevel::L => "L".to_string(),
CorrectLevel::M => "M".to_string(),
CorrectLevel::Q => "Q".to_string(),
CorrectLevel::H => "H".to_string(),
}
}
pub fn get_level_num(&self) -> u32 {
match self {
CorrectLevel::L => 0,
CorrectLevel::M => 1,
CorrectLevel::Q => 2,
CorrectLevel::H => 3,
}
}
}
CBar.swift

完整参数、默认值与命令编码

public class CBar: EasyArg<String> {
public required init(_ raw: CRealBar) {
public static func build(_ block: (DeriveArg<CommandDataType>) -> CRealBar) -> Self {
let derived = DeriveArg<CommandDataType>.make()
return Self.init(block(derived))
}
}
public class CRealBar: IEasyStringArg {
public var _derived: DeriveArg<CommandDataType>;
public var startX: Int
public var startY: Int
public var content: Int
public var height: Int
public var codeType = CCodeType.CODE128
public var codeRotation = CCodeRotation.ROTATE_0
public init(
derived: DeriveArg<CommandDataType>,
startX: Int,
startY: Int,
content: Int,
height: Int,
codeType: CCodeType,
codeRotation: CCodeRotation
) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(codeRotation.rawValue)
.append(codeType.rawValue)
.append(codeType.width())
.append(2)
.append(height)
.append(startX)
.append(startY)
.append(content)
.clause()
}
public func header() -> String {
""
}
public func derived() -> DeriveArg<CommandDataType>? {
self._derived
}
}
CBatteryVolume.swift

完整参数、默认值与命令编码

public class CBatteryVolume: OnlyStringHeaderArg {
public required init() {
public static func build() -> Self {
Self.init()
}
}
class CRealBatteryVolume: IEasyOnlyStringHeaderArg {
CBold.swift — SETBOLD

完整参数、默认值与命令编码

public class CBold: EasyArg<String> {
public required init(_ raw: CRealBold) {
public static func build(_ block: () -> CRealBold) -> Self {
Self.init(block())
}
}
public class CRealBold: IEasyStringArg {
public var isBold: Bool
public init(
isBold: Bool
) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(isBold ? "1":"0")
.clause()
}
public func header() -> String {
"SETBOLD"
}
public func derived() -> DeriveArg<String>? {
nil
}
}
CBox.swift — BOX

完整参数、默认值与命令编码

public class CBox: EasyArg<String> {
public required init(_ raw: CRealBox) {
public static func build(_ block: () -> CRealBox) -> Self {
Self.init(block())
}
}
public class CRealBox: IEasyStringArg {
public var lineWidth: Int
public var topLeftX: Int
public var topLeftY: Int
public var bottomRightX: Int
public var bottomRightY: Int
public init(
topLeftX: Int,
topLeftY: Int,
bottomRightX: Int,
bottomRightY: Int,
lineWidth: Int
) {
public func clause() -> CommandClause {
if (topLeftX > 575) {
public func header() -> String {
"BOX"
}
public func derived() -> DeriveArg<String>? {
nil
}
}
CFeed.swift — ! 0 200 200 0 1

完整参数、默认值与命令编码

public class CFeed: EasyArg<String> {
public required init(_ raw: CRealFeed) {
public static func build(_ block: (DeriveArg<CommandDataType>) -> CRealFeed) -> Self {
let derived = DeriveArg<CommandDataType>.make()
return Self.init(block(derived))
}
}
public class CRealFeed: IEasyStringArg {
public var _derived: DeriveArg<CommandDataType>
public init(
derived: DeriveArg<CommandDataType>
) {
public func clause() -> CommandClause {
let _ = _derived.append(AnyArg.init(base: CPageWidth.build({
() in CRealPageWidth(pageWidth: 576)
}))).append(AnyArg.init(base: CGap.build())).append(AnyArg.init(base: CForm.build())).append(AnyArg.init(base: CNormalPrint.build()))
return CPCLCommand.with(header: header())
.clause()
}
public func header() -> String {
"! 0 200 200 0 1"
}
public func derived() -> DeriveArg<String>? {
self._derived
}
}
CForm.swift — FORM

完整参数、默认值与命令编码

public class CForm: OnlyStringHeaderArg {
public required init() {
public static func build() -> Self {
Self.init()
}
}
class TRealForm: IEasyOnlyStringHeaderArg {
CGap.swift — GAP-SENSE

完整参数、默认值与命令编码

public class CGap: OnlyStringHeaderArg {
public required init() {
public static func build() -> Self {
Self.init()
}
}
class CRealGap: IEasyOnlyStringHeaderArg {
CHorizontalPrint.swift — POPRINT

完整参数、默认值与命令编码

public class CHorizontalPrint: OnlyStringHeaderArg {
public required init() {
public static func build() -> Self {
Self.init()
}
}
class CRealHorizontalPrint: IEasyOnlyStringHeaderArg {
CImage.swift — CG

完整参数、默认值与命令编码

public class CImage: EasyArg<String> {
public required init(_ raw: CRealImage) {
public static func build(_ block: () -> CRealImage) -> Self {
Self.init(block())
}
}
public class CRealImage: IEasyStringArg {
public var startX: Int
public var startY: Int
public var width: Int
public var height: Int
public var image: Data
public var compress: Bool
public init(
startX: Int,
startY: Int,
width: Int,
height: Int,
image: Data,
compress: Bool
) {
public func header() -> String {
"CG"
}
public func clause() -> CommandClause {
let byteWidth: Int = (width % 8 == 0) ? (width / 8) : (width / 8 + 1)
let command = Commander.make()
.push(CPCLCommand.with(header: header())
.append(byteWidth)
.append(height)
.append(startX)
.append(startY)
.clause()
)
.push(" ", newline: false)
.push(image, newline: false)
.newline()
.command()
return Raw.command(command.binary()).clause()
}
public func derived() -> DeriveArg<String>? {
nil
}
}
CInverse.swift — INVERSE-LINE

完整参数、默认值与命令编码

public class CInverse: EasyArg<String> {
public required init(_ raw: CRealInverse) {
public static func build(_ block: () -> CRealInverse) -> Self {
Self.init(block())
}
}
public class CRealInverse: IEasyStringArg {
public var startX: Int
public var startY: Int
public var width: Int
public var height: Int
public var font: CFont = CFont.TSS16
public init(
startX: Int,
startY: Int,
width: Int,
height: Int,
font: CFont
) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(startX)
.append(startY)
.append(startX + width)
.append(startY + font.height())
.append(height)
.clause()
}
public func header() -> String {
"INVERSE-LINE"
}
public func derived() -> DeriveArg<CommandDataType>? {
nil
}
}
CLine.swift — LINE / LPLINE

完整参数、默认值与命令编码

public class CLine: EasyArg<String> {
public required init(_ raw: CRealLine) {
public static func build(_ block: () -> CRealLine) -> Self {
Self.init(block())
}
}
public class CRealLine: IEasyStringArg {
public var startX: Int
public var startY: Int
public var endX: Int
public var endY: Int
public var lineWidth: Int
public var solid: Bool
public init(
startX: Int,
startY: Int,
endX: Int,
endY: Int,
lineWidth: Int,
solid: Bool = true
) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(startX)
.append(startY)
.append(endX)
.append(endY)
.append(lineWidth)
.clause()
}
public func header() -> CommandDataType {
solid ? "LINE" : "LPLINE"
}
public func derived() -> DeriveArg<CommandDataType>? {
nil
}
}
CMag.swift — SETMAG

完整参数、默认值与命令编码

public class CMag: EasyArg<String> {
public required init(_ raw: CRealMag) {
public static func build(_ block: () -> CRealMag) -> Self {
Self.init(block())
}
}
public class CRealMag: IEasyStringArg {
public var font: CFont = CFont.TSS16
public init(font: CFont) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(font.ex())
.append(font.ey())
.clause()
}
public func header() -> String {
"SETMAG"
}
public func derived() -> DeriveArg<CommandDataType>? {
nil
}
}
CNormalPrint.swift — PRINT

完整参数、默认值与命令编码

public class CNormalPrint: OnlyStringHeaderArg {
public required init() {
public static func build() -> Self {
Self.init()
}
}
class TRealNormalPrint: IEasyOnlyStringHeaderArg {
CPageHeight.swift — ! 0 200 200

完整参数、默认值与命令编码

public class CPageHeight: EasyArg<String> {
public required init(_ raw: CRealPageHeight) {
public static func build(_ block: () -> CRealPageHeight) -> Self {
Self.init(block())
}
}
public class CRealPageHeight: IEasyStringArg {
public var pageHeight: Int
public init(pageHeight: Int) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(pageHeight)
.append("1")
.clause()
}
public func header() -> CommandDataType {
"! 0 200 200"
}
public func derived() -> DeriveArg<String>? {
nil
}
}
CPageMode.swift

完整参数、默认值与命令编码

public class CPageMode: EasyArg<String> {
public required init(_ raw: CRealPageMode) {
public static func build(_ block: (DeriveArg<CommandDataType>) -> CRealPageMode) -> Self {
let derived = DeriveArg<CommandDataType>.make()
return Self.init(block(derived))
}
}
public class CRealPageMode: IEasyStringArg {
public var _derived: DeriveArg<CommandDataType>
public var mode: CMode = .NORMAL
public var location: CLocation = .NO_LOCATION
public init(
derived: DeriveArg<CommandDataType>
) {
public func clause() -> CommandClause {
if location.rawValue > 0 {
_derived.prepend(AnyArg.init(base: CGap.build()))
_derived.prepend(AnyArg.init(base: CForm.build()))
}
if mode.rawValue > 0 {
_derived.append(AnyArg.init(base: CHorizontalPrint.build()))
} else {
_derived.append(AnyArg.init(base: CNormalPrint.build()))
}
return CPCLCommand.with(header: header())
.clause()
}
public func header() -> String {
""
}
public func derived() -> DeriveArg<String>? {
self._derived
}
}
CPageSetup.swift

完整参数、默认值与命令编码

public class CPageSetup: EasyArg<String> {
public required init(_ raw: CRealPageSetup) {
public static func build(_ block: (DeriveArg<CommandDataType>) -> CRealPageSetup) -> Self {
let derived = DeriveArg<CommandDataType>.make()
return Self.init(block(derived))
}
}
public class CRealPageSetup: IEasyStringArg {
public var _derived: DeriveArg<CommandDataType>
public var pageWidth: Int
public var pageHeight: Int
public init(
derived: DeriveArg<CommandDataType>,
pageWidth: Int,
pageHeight: Int
) {
public func clause() -> CommandClause {
_derived.prepend(AnyArg.init(base: CPageHeight.build({
() in CRealPageHeight(pageHeight: pageHeight)
})))
_derived.append(AnyArg.init(base: CPageWidth.build({
() in CRealPageWidth(pageWidth: pageWidth)
})))
return CPCLCommand.with(header: header())
.clause()
}
public func header() -> String {
""
}
public func derived() -> DeriveArg<String>? {
self._derived
}
}
CPageWidth.swift — PAGE-WIDTH

完整参数、默认值与命令编码

public class CPageWidth: EasyArg<String> {
public required init(_ raw: CRealPageWidth) {
public static func build(_ block: () -> CRealPageWidth) -> Self {
Self.init(block())
}
}
public class CRealPageWidth: IEasyStringArg {
public var pageWidth: Int
public init(pageWidth: Int) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(pageWidth)
.clause()
}
public func header() -> CommandDataType {
"PAGE-WIDTH"
}
public func derived() -> DeriveArg<String>? {
nil
}
}
CQRCode.swift — SETQRVER

完整参数、默认值与命令编码

public class CQRCode: EasyArg<String> {
public required init(_ raw: CRealQRCode) {
public static func build(_ block: () -> CRealQRCode) -> Self {
Self.init(block())
}
}
public class CRealQRCode: IEasyStringArg {
public var startX: Int
public var startY: Int
public var content: String
public var codeRotation: CCodeRotation = .ROTATE_0
public var width: Int
public var level: CCorrectLevel = .H
public init(
startX: Int,
startY: Int,
content: String,
codeRotation: CCodeRotation,
width: Int,
level: CCorrectLevel
) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append("3" + "\n" + codeRotation.rawValue)
.append("QR")
.append(startX)
.append(startY)
.append("M")
.append("2")
.append("U")
.append(String(width) + "\n" + level.rawValue + "A" + content + "\n" + "ENDQR")
.clause()
}
public func header() -> String {
"SETQRVER"
}
public func derived() -> DeriveArg<String>? {
nil
}
}
CText.swift — TEXT

完整参数、默认值与命令编码

public class CText: EasyArg<String> {
public required init(_ raw: CRealText) {
public static func build(_ block: () -> CRealText) -> Self {
Self.init(block())
}
}
public class CRealText: IEasyStringArg {
public var font: CFont = .TSS16
public var rotation: CRotation = .ROTATE_0
public var textX: Int
public var textY: Int
public var content: String
public init(
font: CFont,
rotation: CRotation,
textX: Int,
textY: Int,
content: String
) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(font.family())
.append(font.size())
.append(textX)
.append(textY)
.append(content)
.clause()
}
public func header() -> String {
"TEXT" + rotation.rawValue
}
public func derived() -> DeriveArg<String>? {
nil
}
}
CUnderLine.swift — UNDERLINE

完整参数、默认值与命令编码

public class CUnderLine: EasyArg<String> {
public required init(_ raw: CRealUnderLine) {
public static func build(_ block: () -> CRealUnderLine) -> Self {
Self.init(block())
}
}
public class CRealUnderLine: IEasyStringArg {
public var underline: Bool
public init(underline: Bool) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(underline ? "ON" : "OFF")
.clause()
}
public func header() -> String {
"UNDERLINE"
}
public func derived() -> DeriveArg<String>? {
nil
}
}
CWaterMark.swift — WAT

完整参数、默认值与命令编码

public class CWaterMark: EasyArg<String> {
public required init(_ raw: CRealWaterMark) {
public static func build(_ block: () -> CRealWaterMark) -> Self {
Self.init(block())
}
}
public class CRealWaterMark: IEasyStringArg {
public var value: Int
public init(value: Int) {
public func clause() -> CommandClause {
CPCLCommand.with(header: header())
.append(value)
.clause()
}
public func header() -> String {
"WAT"
}
public func derived() -> DeriveArg<String>? {
nil
}
}
mark.swift

完整参数、默认值与命令编码

public enum CCodeRotation: String {
public enum CCodeType: String {
public enum CFont {
public enum CCorrectLevel: String {
public enum CRotation: String {
public enum CMode: Int {
public enum CLocation: Int {