diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/controller/AutoReplyPrintController.java b/src/main/java/com/dpkj/modules/autoReplyPrint/controller/AutoReplyPrintController.java new file mode 100644 index 0000000..b3a072d --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/controller/AutoReplyPrintController.java @@ -0,0 +1,37 @@ +package com.dpkj.modules.autoReplyPrint.controller; + +import com.dpkj.common.vo.Result; +import com.dpkj.modules.autoReplyPrint.service.AutoReplyPrintService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * 壁挂打印机 + */ +@Slf4j +@RestController +@RequestMapping("autoReplyPrint") +public class AutoReplyPrintController { + @Autowired + private AutoReplyPrintService autoReplyPrintService; + + /** + * 获取打印机固件版本 + * @return + */ + @GetMapping("CPPrinterGetPrinterFirmwareVersion") + public Result CPPrinterGetPrinterFirmwareVersion() { + try { + return autoReplyPrintService.CPPrinterGetPrinterFirmwareVersion(); + } catch (Exception e) { + e.printStackTrace(); + log.info("获取打印机固件版本失败 {}", e.getMessage()); + return Result.error("获取打印机固件版本失败"); + } + } + +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/service/AutoReplyPrintService.java b/src/main/java/com/dpkj/modules/autoReplyPrint/service/AutoReplyPrintService.java new file mode 100644 index 0000000..f1b75fc --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/service/AutoReplyPrintService.java @@ -0,0 +1,9 @@ +package com.dpkj.modules.autoReplyPrint.service; + + +import com.dpkj.common.vo.Result; + +public interface AutoReplyPrintService { + + Result CPPrinterGetPrinterFirmwareVersion(); +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/AutoReplyPrintServiceImpl.java b/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/AutoReplyPrintServiceImpl.java new file mode 100644 index 0000000..07692c3 --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/AutoReplyPrintServiceImpl.java @@ -0,0 +1,29 @@ +package com.dpkj.modules.autoReplyPrint.service.impl; + +import com.dpkj.common.vo.Result; +import com.dpkj.modules.autoReplyPrint.service.AutoReplyPrintService; +import com.dpkj.modules.autoReplyPrint.utils.AutoReplyPrint; +import com.dpkj.modules.autoReplyPrint.utils.AutoReplyPrint2; +import com.dpkj.modules.autoReplyPrint.utils.MyLibrary; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + + +@Slf4j +@Service +public class AutoReplyPrintServiceImpl implements AutoReplyPrintService { + + private AutoReplyPrint2.AutoReplyPrint2Sdk autoReplyPrint2Sdk = AutoReplyPrint2.getAutoReplyPrint2SDK(); + + public AutoReplyPrintServiceImpl() throws AutoReplyPrint2.AutoReplyPrint2RegistrationException { + } + + + @Override + public Result CPPrinterGetPrinterFirmwareVersion() { + String s = MyLibrary.INSTANCE.CP_Printer_GetPrinterFirmwareVersion(); + //String s = autoReplyPrint2Sdk.CPPrinterGetPrinterFirmwareVersion(); + log.info("壁挂机打印机版本信息{}", s); + return Result.ok(s); + } +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/samplelabel.java b/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/samplelabel.java new file mode 100644 index 0000000..aec9d1f --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/samplelabel.java @@ -0,0 +1,429 @@ +package com.dpkj.modules.autoReplyPrint.service.impl; + +import com.dpkj.modules.autoReplyPrint.utils.AutoReplyPrint; +import com.dpkj.modules.autoReplyPrint.utils.TestFunction; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class samplelabel { + + @SuppressWarnings("serial") + class GroupBoxPort extends JPanel implements ActionListener { + + public JRadioButton rbCom = new JRadioButton(); + public JRadioButton rbTcp = new JRadioButton(); + public JRadioButton rbUsb = new JRadioButton(); + public ButtonGroup rbGroup = new ButtonGroup(); + + public JComboBox cbxComName = new JComboBox(); + public JComboBox cbxComBaudrate = new JComboBox(); + public JTextField editIPAddress = new JTextField(); + public JTextField editTcpPort = new JTextField(); + public JComboBox cbxUsbName = new JComboBox(); + + public GroupBoxPort() { + this.setLayout(null); + this.setSize(760, 120); + this.setBorder(BorderFactory.createTitledBorder("Select Port")); + + rbGroup.add(rbCom); + rbGroup.add(rbTcp); + rbGroup.add(rbUsb); + + rbCom.setText("COM"); + rbCom.setBounds(10, 20, 60, 30); + this.add(rbCom); + + rbTcp.setText("TCP"); + rbTcp.setBounds(10, 50, 60, 30); + this.add(rbTcp); + + rbUsb.setText("USB"); + rbUsb.setBounds(10, 80, 60, 30); + this.add(rbUsb); + + cbxComName.setBounds(70, 20, 600, 30); + this.add(cbxComName); + cbxComBaudrate.setBounds(670, 20, 80, 30); + this.add(cbxComBaudrate); + editIPAddress.setBounds(70, 50, 600, 31); + this.add(editIPAddress); + editTcpPort.setBounds(670, 50, 81, 31); + this.add(editTcpPort); + cbxUsbName.setBounds(70, 80, 680, 30); + this.add(cbxUsbName); + + rbUsb.setSelected(true); + editIPAddress.setText("192.168.1.87"); + editTcpPort.setText("9100"); + String[] ComBaudrateStringList = {"1200", "2400", "4800", "9600", "19200", "38400", "57600", "115200", + "230400", "256000", "500000", "750000", "1125000", "1500000"}; + for (String baudrate : ComBaudrateStringList) + cbxComBaudrate.addItem(baudrate); + cbxComBaudrate.setSelectedIndex(7); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + + } + } + + @SuppressWarnings("serial") + class TestForm extends JFrame implements ActionListener { + + String[] testFunctionOrderedList = new String[]{ + + "Test_Label_SampleTicket_58MM_1", + "Test_Label_SampleTicket_80MM_1", + + "Test_Port_Write", + "Test_Port_Read", + "Test_Port_Available", + "Test_Port_SkipAvailable", + "Test_Port_IsConnectionValid", + + "Test_Printer_GetPrinterInfo", + "Test_Printer_ClearPrinterBuffer", + "Test_Printer_ClearPrinterError", + + "Test_Pos_QueryPrintResult", + + "Test_Pos_KickOutDrawer", + "Test_Pos_Beep", + + "Test_Pos_PrintSelfTestPage", + + "Test_Label_EnableLabelMode", + "Test_Label_DisableLabelMode", + "Test_Label_CalibrateLabel", + "Test_Label_FeedLabel", + "Test_Label_SetLabelPositionAdjustment", + "Test_Label_PageBegin_PagePrint", + "Test_Label_DrawText", + "Test_Label_DrawBarcode_UPCA", + "Test_Label_DrawBarcode_UPCE", + "Test_Label_DrawBarcode_EAN13", + "Test_Label_DrawBarcode_EAN8", + "Test_Label_DrawBarcode_CODE39", + "Test_Label_DrawBarcode_ITF", + "Test_Label_DrawBarcode_CODEBAR", + "Test_Label_DrawBarcode_CODE93", + "Test_Label_DrawBarcode_CODE128", + "Test_Label_DrawQRCode", + "Test_Label_DrawPDF417Code", + "Test_Label_DrawLine", + "Test_Label_DrawRect", + "Test_Label_DrawBox", + "Test_Label_DrawImageFromBufferedImage", + }; + + GroupBoxPort groupBoxPort = new GroupBoxPort(); + JButton btnEnumPort = new JButton(); + JButton btnOpenPort = new JButton(); + JButton btnClosePort = new JButton(); + JList listFunction = new JList(testFunctionOrderedList); + JScrollPane scrollFunction = new JScrollPane(listFunction); + JLabel labelFirmwareVersion = new JLabel(); + JLabel labelResolution = new JLabel(); + JLabel labelErrorStatus = new JLabel(); + JLabel labelInfoStatus = new JLabel(); + JLabel labelPrinterReceivedByteCount = new JLabel(); + JLabel labelPrinterPrintedPageID = new JLabel(); + Pointer h = Pointer.NULL; + AutoReplyPrint.CP_OnPortClosedEvent_Callback closed_callback = new AutoReplyPrint.CP_OnPortClosedEvent_Callback() { + @Override + public void CP_OnPortClosedEvent(Pointer handle, Pointer private_data) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + btnClosePort.doClick(); + } + }); + } + }; + AutoReplyPrint.CP_OnPrinterStatusEvent_Callback status_callback = new AutoReplyPrint.CP_OnPrinterStatusEvent_Callback() { + @Override + public void CP_OnPrinterStatusEvent(Pointer h, final long printer_error_status, + final long printer_info_status, Pointer private_data) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Calendar calendar = Calendar.getInstance(); + Date calendarDate = calendar.getTime(); + String time = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss").format(calendarDate); + AutoReplyPrint.CP_PrinterStatus status = new AutoReplyPrint.CP_PrinterStatus( + printer_error_status, printer_info_status); + String error_status_string = String.format(" Printer Error Status: 0x%04X", + printer_error_status & 0xffff); + if (status.ERROR_OCCURED()) { + if (status.ERROR_CUTTER()) + error_status_string += "[ERROR_CUTTER]"; + if (status.ERROR_FLASH()) + error_status_string += "[ERROR_FLASH]"; + if (status.ERROR_NOPAPER()) + error_status_string += "[ERROR_NOPAPER]"; + if (status.ERROR_VOLTAGE()) + error_status_string += "[ERROR_VOLTAGE]"; + if (status.ERROR_MARKER()) + error_status_string += "[ERROR_MARKER]"; + if (status.ERROR_ENGINE()) + error_status_string += "[ERROR_ENGINE]"; + if (status.ERROR_OVERHEAT()) + error_status_string += "[ERROR_OVERHEAT]"; + if (status.ERROR_COVERUP()) + error_status_string += "[ERROR_COVERUP]"; + if (status.ERROR_MOTOR()) + error_status_string += "[ERROR_MOTOR]"; + } + String info_status_string = String.format(" Printer Info Status: 0x%04X", + printer_info_status & 0xffff); + if (status.INFO_LABELMODE()) + info_status_string += "[Label Mode]"; + if (status.INFO_LABELPAPER()) + info_status_string += "[Label Paper]"; + if (status.INFO_PAPERNOFETCH()) + info_status_string += "[Paper Not Fetch]"; + labelErrorStatus.setText(time + error_status_string); + labelInfoStatus.setText(time + info_status_string); + } + }); + } + }; + AutoReplyPrint.CP_OnPrinterReceivedEvent_Callback received_callback = new AutoReplyPrint.CP_OnPrinterReceivedEvent_Callback() { + @Override + public void CP_OnPrinterReceivedEvent(Pointer h, final int printer_received_byte_count, + Pointer private_data) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Calendar calendar = Calendar.getInstance(); + Date calendarDate = calendar.getTime(); + String time = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss").format(calendarDate); + labelPrinterReceivedByteCount + .setText(time + " PrinterReceived: " + printer_received_byte_count); + } + }); + } + }; + AutoReplyPrint.CP_OnPrinterPrintedEvent_Callback printed_callback = new AutoReplyPrint.CP_OnPrinterPrintedEvent_Callback() { + @Override + public void CP_OnPrinterPrintedEvent(Pointer h, final int printer_printed_page_id, Pointer private_data) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Calendar calendar = Calendar.getInstance(); + Date calendarDate = calendar.getTime(); + String time = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss").format(calendarDate); + labelPrinterPrintedPageID.setText(time + " PrinterPrinted: " + printer_printed_page_id); + } + }); + } + }; + + private void AddCallback() { + AutoReplyPrint.INSTANCE.CP_Port_AddOnPortClosedEvent(closed_callback, Pointer.NULL); + AutoReplyPrint.INSTANCE.CP_Printer_AddOnPrinterStatusEvent(status_callback, Pointer.NULL); + AutoReplyPrint.INSTANCE.CP_Printer_AddOnPrinterReceivedEvent(received_callback, Pointer.NULL); + AutoReplyPrint.INSTANCE.CP_Printer_AddOnPrinterPrintedEvent(printed_callback, Pointer.NULL); + } + + private void RemoveCallback() { + AutoReplyPrint.INSTANCE.CP_Port_RemoveOnPortClosedEvent(closed_callback); + AutoReplyPrint.INSTANCE.CP_Printer_RemoveOnPrinterStatusEvent(status_callback); + AutoReplyPrint.INSTANCE.CP_Printer_RemoveOnPrinterReceivedEvent(received_callback); + AutoReplyPrint.INSTANCE.CP_Printer_RemoveOnPrinterPrintedEvent(printed_callback); + } + + public TestForm() { + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLayout(null); + this.setVisible(true); + this.setSize(800, 700); + this.setTitle(AutoReplyPrint.INSTANCE.CP_Library_Version()); + + groupBoxPort.setLocation(10, 10); + this.add(groupBoxPort); + + btnEnumPort.setBounds(20, 140, 240, 30); + btnEnumPort.setText("EnumPort"); + btnEnumPort.addActionListener(this); + this.add(btnEnumPort); + btnOpenPort.setBounds(270, 140, 240, 30); + btnOpenPort.setText("OpenPort"); + btnOpenPort.addActionListener(this); + this.add(btnOpenPort); + btnClosePort.setBounds(520, 140, 240, 30); + btnClosePort.setText("ClosePort"); + btnClosePort.addActionListener(this); + this.add(btnClosePort); + + labelFirmwareVersion.setBounds(20, 460, 740, 30); + labelFirmwareVersion.setText("Firmware Version:"); + this.add(labelFirmwareVersion); + labelResolution.setBounds(20, 490, 740, 30); + labelResolution.setText("Resolution:"); + this.add(labelResolution); + labelErrorStatus.setBounds(20, 520, 740, 30); + labelErrorStatus.setText("Error Status:"); + this.add(labelErrorStatus); + labelInfoStatus.setBounds(20, 550, 740, 30); + labelInfoStatus.setText("Info Status:"); + this.add(labelInfoStatus); + labelPrinterReceivedByteCount.setBounds(20, 580, 740, 30); + labelPrinterReceivedByteCount.setText("Printer Received Byte Count:"); + this.add(labelPrinterReceivedByteCount); + labelPrinterPrintedPageID.setBounds(20, 610, 740, 30); + labelPrinterPrintedPageID.setText("Printer Printed Page ID:"); + this.add(labelPrinterPrintedPageID); + + scrollFunction.setBounds(20, 180, 740, 270); + this.add(scrollFunction); + listFunction.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + // listFunction.addListSelectionListener(this); + listFunction.addMouseListener(new MouseListener() { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + if (e.getSource() == listFunction) { + String functionName = listFunction.getSelectedValue().toString(); + if ((functionName == null) || (functionName.isEmpty())) + return; + try { + TestFunction fun = new TestFunction(); + Method m = TestFunction.class.getDeclaredMethod(functionName, Pointer.class); + m.invoke(fun, h); + } catch (Throwable tr) { + tr.printStackTrace(); + } + } + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + }); + + btnEnumPort.doClick(); + refreshUI(); + + AddCallback(); + } + + protected void finalize() throws Throwable { + RemoveCallback(); + super.finalize(); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == btnEnumPort) { + String[] port_list = null; + + groupBoxPort.cbxComName.removeAllItems(); + port_list = AutoReplyPrint.CP_Port_EnumCom_Helper.EnumCom(); + if (port_list != null) { + for (String port : port_list) + groupBoxPort.cbxComName.addItem(port); + } + + groupBoxPort.cbxUsbName.removeAllItems(); + port_list = AutoReplyPrint.CP_Port_EnumUsb_Helper.EnumUsb(); + if (port_list != null) { + for (String port : port_list) + groupBoxPort.cbxUsbName.addItem(port); + } + + } else if (e.getSource() == btnOpenPort) { + if (groupBoxPort.rbCom.isSelected()) { + if (groupBoxPort.cbxComName.getSelectedItem() == null) + return; + String name = groupBoxPort.cbxComName.getSelectedItem().toString(); + int baudrate = Integer.parseInt(groupBoxPort.cbxComBaudrate.getSelectedItem().toString()); + h = AutoReplyPrint.INSTANCE.CP_Port_OpenCom(name, baudrate, AutoReplyPrint.CP_ComDataBits_8, + AutoReplyPrint.CP_ComParity_NoParity, AutoReplyPrint.CP_ComStopBits_One, AutoReplyPrint.CP_ComFlowControl_None, + 1); + } else if (groupBoxPort.rbUsb.isSelected()) { + if (groupBoxPort.cbxUsbName.getSelectedItem() == null) + return; + String name = groupBoxPort.cbxUsbName.getSelectedItem().toString(); + h = AutoReplyPrint.INSTANCE.CP_Port_OpenUsb(name, 1); + } else if (groupBoxPort.rbTcp.isSelected()) { + String ip = groupBoxPort.editIPAddress.getText(); + int port = Integer.parseInt(groupBoxPort.editTcpPort.getText()); + h = AutoReplyPrint.INSTANCE.CP_Port_OpenTcp(null, ip, (short) port, 5000, 1); + } + refreshUI(); + } else if (e.getSource() == btnClosePort) { + if (h != Pointer.NULL) { + AutoReplyPrint.INSTANCE.CP_Port_Close(h); + h = Pointer.NULL; + } + refreshUI(); + } + } + + private void refreshUI() { + groupBoxPort.setEnabled(h == Pointer.NULL); + btnEnumPort.setEnabled(h == Pointer.NULL); + btnOpenPort.setEnabled(h == Pointer.NULL); + btnClosePort.setEnabled(h != Pointer.NULL); + listFunction.setEnabled(h != Pointer.NULL); + if (h != Pointer.NULL) { + labelFirmwareVersion.setText("Firmware Version: " + + AutoReplyPrint.CP_Printer_GetPrinterFirmwareVersion_Helper.GetPrinterFirmwareVersion(h)); + IntByReference width_mm = new IntByReference(); + IntByReference height_mm = new IntByReference(); + IntByReference dots_per_mm = new IntByReference(); + if (AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterResolutionInfo(h, width_mm, height_mm, dots_per_mm)) { + labelResolution.setText("Resolution: " + "width:" + width_mm.getValue() + "mm " + "height:" + + height_mm.getValue() + "mm " + "dots_per_mm:" + dots_per_mm.getValue()); + } + } + } + + } + + static TestForm testform; + + public static void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + testform = new samplelabel().new TestForm(); + } + }); + } +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/utils/AutoReplyPrint.java b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/AutoReplyPrint.java new file mode 100644 index 0000000..4908ddd --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/AutoReplyPrint.java @@ -0,0 +1,849 @@ +package com.dpkj.modules.autoReplyPrint.utils; + +import com.sun.jna.*; +import com.sun.jna.ptr.DoubleByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; + +public interface AutoReplyPrint extends Library { + AutoReplyPrint INSTANCE = (AutoReplyPrint) Native.loadLibrary(GetLibraryPath_Helper.GetLibraryPath(), AutoReplyPrint.class); + int CP_ComDataBits_4 = 4; + int CP_ComDataBits_5 = 5; + int CP_ComDataBits_6 = 6; + int CP_ComDataBits_7 = 7; + int CP_ComDataBits_8 = 8; + int CP_ComParity_NoParity = 0; + int CP_ComParity_OddParity = 1; + int CP_ComParity_EvenParity = 2; + int CP_ComParity_MarkParity = 3; + int CP_ComParity_SpaceParity = 4; + int CP_ComStopBits_One = 0; + int CP_ComStopBits_OnePointFive = 1; + int CP_ComStopBits_Two = 2; + int CP_ComFlowControl_None = 0; + int CP_ComFlowControl_XonXoff = 1; + int CP_ComFlowControl_RtsCts = 2; + int CP_ComFlowControl_DtrDsr = 3; + int CP_CharacterSet_USA = 0; + int CP_CharacterSet_FRANCE = 1; + int CP_CharacterSet_GERMANY = 2; + int CP_CharacterSet_UK = 3; + int CP_CharacterSet_DENMARK_I = 4; + int CP_CharacterSet_SWEDEN = 5; + int CP_CharacterSet_ITALY = 6; + int CP_CharacterSet_SPAIN_I = 7; + int CP_CharacterSet_JAPAN = 8; + int CP_CharacterSet_NORWAY = 9; + int CP_CharacterSet_DENMARK_II = 10; + int CP_CharacterSet_SPAIN_II = 11; + int CP_CharacterSet_LATIN = 12; + int CP_CharacterSet_KOREA = 13; + int CP_CharacterSet_SLOVENIA = 14; + int CP_CharacterSet_CHINA = 15; + int CP_CharacterCodepage_CP437 = 0; + int CP_CharacterCodepage_KATAKANA = 1; + int CP_CharacterCodepage_CP850 = 2; + int CP_CharacterCodepage_CP860 = 3; + int CP_CharacterCodepage_CP863 = 4; + int CP_CharacterCodepage_CP865 = 5; + int CP_CharacterCodepage_WCP1251 = 6; + int CP_CharacterCodepage_CP866 = 7; + int CP_CharacterCodepage_MIK = 8; + int CP_CharacterCodepage_CP755 = 9; + int CP_CharacterCodepage_IRAN = 10; + int CP_CharacterCodepage_CP862 = 15; + int CP_CharacterCodepage_WCP1252 = 16; + int CP_CharacterCodepage_WCP1253 = 17; + int CP_CharacterCodepage_CP852 = 18; + int CP_CharacterCodepage_CP858 = 19; + int CP_CharacterCodepage_IRAN_II = 20; + int CP_CharacterCodepage_LATVIAN = 21; + int CP_CharacterCodepage_CP864 = 22; + int CP_CharacterCodepage_ISO_8859_1 = 23; + int CP_CharacterCodepage_CP737 = 24; + int CP_CharacterCodepage_WCP1257 = 25; + int CP_CharacterCodepage_THAI = 26; + int CP_CharacterCodepage_CP720 = 27; + int CP_CharacterCodepage_CP855 = 28; + int CP_CharacterCodepage_CP857 = 29; + int CP_CharacterCodepage_WCP1250 = 30; + int CP_CharacterCodepage_CP775 = 31; + int CP_CharacterCodepage_WCP1254 = 32; + int CP_CharacterCodepage_WCP1255 = 33; + int CP_CharacterCodepage_WCP1256 = 34; + int CP_CharacterCodepage_WCP1258 = 35; + int CP_CharacterCodepage_ISO_8859_2 = 36; + int CP_CharacterCodepage_ISO_8859_3 = 37; + int CP_CharacterCodepage_ISO_8859_4 = 38; + int CP_CharacterCodepage_ISO_8859_5 = 39; + int CP_CharacterCodepage_ISO_8859_6 = 40; + int CP_CharacterCodepage_ISO_8859_7 = 41; + int CP_CharacterCodepage_ISO_8859_8 = 42; + int CP_CharacterCodepage_ISO_8859_9 = 43; + int CP_CharacterCodepage_ISO_8859_15 = 44; + int CP_CharacterCodepage_THAI_2 = 45; + int CP_CharacterCodepage_CP856 = 46; + int CP_CharacterCodepage_CP874 = 47; + int CP_CharacterCodepage_TCVN3 = 48; + int CP_MultiByteEncoding_GBK = 0; + int CP_MultiByteEncoding_UTF8 = 1; + int CP_MultiByteEncoding_BIG5 = 3; + int CP_MultiByteEncoding_ShiftJIS = 4; + int CP_MultiByteEncoding_EUCKR = 5; + int CP_ImageBinarizationMethod_Dithering = 0; + int CP_ImageBinarizationMethod_Thresholding = 1; + int CP_ImageBinarizationMethod_ErrorDiffusion = 2; + int CP_ImageCompressionMethod_None = 0; + int CP_ImageCompressionMethod_Level1 = 1; + int CP_ImageCompressionMethod_Level2 = 2; + int CP_ImagePixelsFormat_MONO = 1; + int CP_ImagePixelsFormat_MONOLSB = 2; + int CP_ImagePixelsFormat_GRAY8 = 3; + int CP_ImagePixelsFormat_BYTEORDERED_RGB24 = 4; + int CP_ImagePixelsFormat_BYTEORDERED_BGR24 = 5; + int CP_ImagePixelsFormat_BYTEORDERED_ARGB32 = 6; + int CP_ImagePixelsFormat_BYTEORDERED_RGBA32 = 7; + int CP_ImagePixelsFormat_BYTEORDERED_ABGR32 = 8; + int CP_ImagePixelsFormat_BYTEORDERED_BGRA32 = 9; + int CP_QRCodeECC_L = 1; + int CP_QRCodeECC_M = 2; + int CP_QRCodeECC_Q = 3; + int CP_QRCodeECC_H = 4; + int CP_Pos_Alignment_Left = 0; + int CP_Pos_Alignment_HCenter = 1; + int CP_Pos_Alignment_Right = 2; + int CP_Pos_BarcodeType_UPCA = 65; + int CP_Pos_BarcodeType_UPCE = 66; + int CP_Pos_BarcodeType_EAN13 = 67; + int CP_Pos_BarcodeType_EAN8 = 68; + int CP_Pos_BarcodeType_CODE39 = 69; + int CP_Pos_BarcodeType_ITF = 70; + int CP_Pos_BarcodeType_CODEBAR = 71; + int CP_Pos_BarcodeType_CODE93 = 72; + int CP_Pos_BarcodeType_CODE128 = 73; + int CP_Pos_BarcodeTextPrintPosition_None = 0; + int CP_Pos_BarcodeTextPrintPosition_AboveBarcode = 1; + int CP_Pos_BarcodeTextPrintPosition_BelowBarcode = 2; + int CP_Pos_BarcodeTextPrintPosition_AboveAndBelowBarcode = 3; + int CP_Page_DrawDirection_LeftToRight = 0; + int CP_Page_DrawDirection_BottomToTop = 1; + int CP_Page_DrawDirection_RightToLeft = 2; + int CP_Page_DrawDirection_TopToBottom = 3; + int CP_Page_DrawAlignment_Left = -1; + int CP_Page_DrawAlignment_HCenter = -2; + int CP_Page_DrawAlignment_Right = -3; + int CP_Page_DrawAlignment_Top = -1; + int CP_Page_DrawAlignment_VCenter = -2; + int CP_Page_DrawAlignment_Bottom = -3; + int CP_Label_BarcodeType_UPCA = 0; + int CP_Label_BarcodeType_UPCE = 1; + int CP_Label_BarcodeType_EAN13 = 2; + int CP_Label_BarcodeType_EAN8 = 3; + int CP_Label_BarcodeType_CODE39 = 4; + int CP_Label_BarcodeType_ITF = 5; + int CP_Label_BarcodeType_CODEBAR = 6; + int CP_Label_BarcodeType_CODE93 = 7; + int CP_Label_BarcodeType_CODE128 = 8; + int CP_Label_BarcodeType_CODE11 = 9; + int CP_Label_BarcodeType_MSI = 10; + int CP_Label_BarcodeType_128M = 11; + int CP_Label_BarcodeType_EAN128 = 12; + int CP_Label_BarcodeType_25C = 13; + int CP_Label_BarcodeType_39C = 14; + int CP_Label_BarcodeType_39 = 15; + int CP_Label_BarcodeType_EAN13PLUS2 = 16; + int CP_Label_BarcodeType_EAN13PLUS5 = 17; + int CP_Label_BarcodeType_EAN8PLUS2 = 18; + int CP_Label_BarcodeType_EAN8PLUS5 = 19; + int CP_Label_BarcodeType_POST = 20; + int CP_Label_BarcodeType_UPCAPLUS2 = 21; + int CP_Label_BarcodeType_UPCAPLUS5 = 22; + int CP_Label_BarcodeType_UPCEPLUS2 = 23; + int CP_Label_BarcodeType_UPCEPLUS5 = 24; + int CP_Label_BarcodeType_CPOST = 25; + int CP_Label_BarcodeType_MSIC = 26; + int CP_Label_BarcodeType_PLESSEY = 27; + int CP_Label_BarcodeType_ITF14 = 28; + int CP_Label_BarcodeType_EAN14 = 29; + int CP_Label_BarcodeTextPrintPosition_None = 0; + int CP_Label_BarcodeTextPrintPosition_AboveBarcode = 1; + int CP_Label_BarcodeTextPrintPosition_BelowBarcode = 2; + int CP_Label_BarcodeTextPrintPosition_AboveAndBelowBarcode = 3; + int CP_Label_Rotation_0 = 0; + int CP_Label_Rotation_90 = 1; + int CP_Label_Rotation_180 = 2; + int CP_Label_Rotation_270 = 3; + int CP_Label_Color_White = 0; + int CP_Label_Color_Black = 1; + + String CP_Library_Version(); + + int CP_Port_EnumCom(byte[] var1, int var2, IntByReference var3); + + int CP_Port_EnumLpt(byte[] var1, int var2, IntByReference var3); + + int CP_Port_EnumUsb(byte[] var1, int var2, IntByReference var3); + + void CP_Port_EnumNetPrinter(int var1, IntByReference var2, CP_OnNetPrinterDiscovered_Callback var3, Pointer var4); + + void CP_Port_EnumBtDevice(int var1, IntByReference var2, CP_OnBluetoothDeviceDiscovered_Callback var3, Pointer var4); + + void CP_Port_EnumBleDevice(int var1, IntByReference var2, CP_OnBluetoothDeviceDiscovered_Callback var3, Pointer var4); + + Pointer CP_Port_OpenCom(String var1, int var2, int var3, int var4, int var5, int var6, int var7); + + Pointer CP_Port_OpenLpt(String var1); + + Pointer CP_Port_OpenUsb(String var1, int var2); + + Pointer CP_Port_OpenTcp(String var1, String var2, short var3, int var4, int var5); + + Pointer CP_Port_OpenBtSpp(String var1, int var2); + + Pointer CP_Port_OpenBtBle(String var1, int var2); + + int CP_Port_Write(Pointer var1, byte[] var2, int var3, int var4); + + int CP_Port_Read(Pointer var1, byte[] var2, int var3, int var4); + + int CP_Port_ReadUntilByte(Pointer var1, byte[] var2, int var3, int var4, byte var5); + + int CP_Port_Available(Pointer var1); + + boolean CP_Port_SkipAvailable(Pointer var1); + + boolean CP_Port_IsConnectionValid(Pointer var1); + + boolean CP_Port_IsOpened(Pointer var1); + + boolean CP_Port_Close(Pointer var1); + + boolean CP_Port_AddOnPortOpenedEvent(CP_OnPortOpenedEvent_Callback var1, Pointer var2); + + boolean CP_Port_AddOnPortOpenFailedEvent(CP_OnPortOpenFailedEvent_Callback var1, Pointer var2); + + boolean CP_Port_AddOnPortClosedEvent(CP_OnPortClosedEvent_Callback var1, Pointer var2); + + boolean CP_Port_AddOnPortWrittenEvent(CP_OnPortWrittenEvent_Callback var1, Pointer var2); + + boolean CP_Port_AddOnPortReceivedEvent(CP_OnPortReceivedEvent_Callback var1, Pointer var2); + + boolean CP_Port_RemoveOnPortOpenedEvent(CP_OnPortOpenedEvent_Callback var1); + + boolean CP_Port_RemoveOnPortOpenFailedEvent(CP_OnPortOpenFailedEvent_Callback var1); + + boolean CP_Port_RemoveOnPortClosedEvent(CP_OnPortClosedEvent_Callback var1); + + boolean CP_Port_RemoveOnPortWrittenEvent(CP_OnPortWrittenEvent_Callback var1); + + boolean CP_Port_RemoveOnPortReceivedEvent(CP_OnPortReceivedEvent_Callback var1); + + boolean CP_Printer_AddOnPrinterStatusEvent(CP_OnPrinterStatusEvent_Callback var1, Pointer var2); + + boolean CP_Printer_AddOnPrinterReceivedEvent(CP_OnPrinterReceivedEvent_Callback var1, Pointer var2); + + boolean CP_Printer_AddOnPrinterPrintedEvent(CP_OnPrinterPrintedEvent_Callback var1, Pointer var2); + + boolean CP_Printer_RemoveOnPrinterStatusEvent(CP_OnPrinterStatusEvent_Callback var1); + + boolean CP_Printer_RemoveOnPrinterReceivedEvent(CP_OnPrinterReceivedEvent_Callback var1); + + boolean CP_Printer_RemoveOnPrinterPrintedEvent(CP_OnPrinterPrintedEvent_Callback var1); + + boolean CP_Printer_GetPrinterResolutionInfo(Pointer var1, IntByReference var2, IntByReference var3, IntByReference var4); + + boolean CP_Printer_GetPrinterFirmwareVersion(Pointer var1, byte[] var2, int var3, IntByReference var4); + + boolean CP_Printer_GetPrinterStatusInfo(Pointer var1, LongByReference var2, LongByReference var3, LongByReference var4); + + boolean CP_Printer_GetPrinterReceivedInfo(Pointer var1, IntByReference var2, LongByReference var3); + + boolean CP_Printer_GetPrinterPrintedInfo(Pointer var1, IntByReference var2, LongByReference var3); + + boolean CP_Printer_GetPrinterLabelPositionAdjustmentInfo(Pointer var1, DoubleByReference var2, DoubleByReference var3, LongByReference var4); + + boolean CP_Printer_SetPrinterLabelPositionAdjustmentInfo(Pointer var1, double var2, double var4); + + boolean CP_Printer_ClearPrinterBuffer(Pointer var1); + + boolean CP_Printer_ClearPrinterError(Pointer var1); + + int CP_Pos_QueryRTStatus(Pointer var1, int var2); + + boolean CP_Pos_QueryPrintResult(Pointer var1, int var2); + + boolean CP_Pos_KickOutDrawer(Pointer var1, int var2, int var3, int var4); + + boolean CP_Pos_Beep(Pointer var1, int var2, int var3); + + boolean CP_Pos_FeedAndHalfCutPaper(Pointer var1); + + boolean CP_Pos_FullCutPaper(Pointer var1); + + boolean CP_Pos_HalfCutPaper(Pointer var1); + + boolean CP_Pos_FeedLine(Pointer var1, int var2); + + boolean CP_Pos_FeedDot(Pointer var1, int var2); + + boolean CP_Pos_PrintSelfTestPage(Pointer var1); + + boolean CP_Pos_PrintText(Pointer var1, String var2); + + boolean CP_Pos_PrintTextInUTF8(Pointer var1, WString var2); + + boolean CP_Pos_PrintTextInGBK(Pointer var1, WString var2); + + boolean CP_Pos_PrintTextInBIG5(Pointer var1, WString var2); + + boolean CP_Pos_PrintTextInShiftJIS(Pointer var1, WString var2); + + boolean CP_Pos_PrintTextInEUCKR(Pointer var1, WString var2); + + boolean CP_Pos_PrintBarcode(Pointer var1, int var2, String var3); + + boolean CP_Pos_PrintBarcode_Code128Auto(Pointer var1, String var2); + + boolean CP_Pos_PrintQRCode(Pointer var1, int var2, int var3, String var4); + + boolean CP_Pos_PrintQRCodeUseEpsonCmd(Pointer var1, int var2, int var3, String var4); + + boolean CP_Pos_PrintDoubleQRCode(Pointer var1, int var2, int var3, int var4, int var5, String var6, int var7, int var8, int var9, String var10); + + boolean CP_Pos_PrintPDF417BarcodeUseEpsonCmd(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7, String var8); + + boolean CP_Pos_PrintRasterImageFromFile(Pointer var1, int var2, int var3, String var4, int var5, int var6); + + boolean CP_Pos_PrintRasterImageFromData(Pointer var1, int var2, int var3, byte[] var4, int var5, int var6, int var7); + + boolean CP_Pos_PrintRasterImageFromPixels(Pointer var1, byte[] var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9); + + boolean CP_Pos_PrintHorizontalLine(Pointer var1, int var2, int var3); + + boolean CP_Pos_PrintHorizontalLineSpecifyThickness(Pointer var1, int var2, int var3, int var4); + + boolean CP_Pos_PrintMultipleHorizontalLinesAtOneRow(Pointer var1, int var2, int[] var3, int[] var4); + + boolean CP_Pos_ResetPrinter(Pointer var1); + + boolean CP_Pos_SetPrintSpeed(Pointer var1, int var2); + + boolean CP_Pos_SetPrintDensity(Pointer var1, int var2); + + boolean CP_Pos_SetSingleByteMode(Pointer var1); + + boolean CP_Pos_SetCharacterSet(Pointer var1, int var2); + + boolean CP_Pos_SetCharacterCodepage(Pointer var1, int var2); + + boolean CP_Pos_SetMultiByteMode(Pointer var1); + + boolean CP_Pos_SetMultiByteEncoding(Pointer var1, int var2); + + boolean CP_Pos_SetMovementUnit(Pointer var1, int var2, int var3); + + boolean CP_Pos_SetPrintAreaLeftMargin(Pointer var1, int var2); + + boolean CP_Pos_SetPrintAreaWidth(Pointer var1, int var2); + + boolean CP_Pos_SetHorizontalAbsolutePrintPosition(Pointer var1, int var2); + + boolean CP_Pos_SetHorizontalRelativePrintPosition(Pointer var1, int var2); + + boolean CP_Pos_SetVerticalAbsolutePrintPosition(Pointer var1, int var2); + + boolean CP_Pos_SetVerticalRelativePrintPosition(Pointer var1, int var2); + + boolean CP_Pos_SetAlignment(Pointer var1, int var2); + + boolean CP_Pos_SetTextScale(Pointer var1, int var2, int var3); + + boolean CP_Pos_SetAsciiTextFontType(Pointer var1, int var2); + + boolean CP_Pos_SetTextBold(Pointer var1, int var2); + + boolean CP_Pos_SetTextUnderline(Pointer var1, int var2); + + boolean CP_Pos_SetTextUpsideDown(Pointer var1, int var2); + + boolean CP_Pos_SetTextWhiteOnBlack(Pointer var1, int var2); + + boolean CP_Pos_SetTextRotate(Pointer var1, int var2); + + boolean CP_Pos_SetTextLineHeight(Pointer var1, int var2); + + boolean CP_Pos_SetAsciiTextCharRightSpacing(Pointer var1, int var2); + + boolean CP_Pos_SetKanjiTextCharSpacing(Pointer var1, int var2, int var3); + + boolean CP_Pos_SetBarcodeUnitWidth(Pointer var1, int var2); + + boolean CP_Pos_SetBarcodeHeight(Pointer var1, int var2); + + boolean CP_Pos_SetBarcodeReadableTextFontType(Pointer var1, int var2); + + boolean CP_Pos_SetBarcodeReadableTextPosition(Pointer var1, int var2); + + boolean CP_Page_SelectPageMode(Pointer var1); + + boolean CP_Page_SelectPageModeEx(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7); + + boolean CP_Page_ExitPageMode(Pointer var1); + + boolean CP_Page_PrintPage(Pointer var1); + + boolean CP_Page_ClearPage(Pointer var1); + + boolean CP_Page_SetPageArea(Pointer var1, int var2, int var3, int var4, int var5); + + boolean CP_Page_SetPageDrawDirection(Pointer var1, int var2); + + boolean CP_Page_DrawRect(Pointer var1, int var2, int var3, int var4, int var5, int var6); + + boolean CP_Page_DrawBox(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7); + + boolean CP_Page_DrawText(Pointer var1, int var2, int var3, String var4); + + boolean CP_Page_DrawTextInUTF8(Pointer var1, int var2, int var3, WString var4); + + boolean CP_Page_DrawTextInGBK(Pointer var1, int var2, int var3, WString var4); + + boolean CP_Page_DrawTextInBIG5(Pointer var1, int var2, int var3, WString var4); + + boolean CP_Page_DrawTextInShiftJIS(Pointer var1, int var2, int var3, WString var4); + + boolean CP_Page_DrawTextInEUCKR(Pointer var1, int var2, int var3, WString var4); + + boolean CP_Page_DrawBarcode(Pointer var1, int var2, int var3, int var4, String var5); + + boolean CP_Page_DrawQRCode(Pointer var1, int var2, int var3, int var4, int var5, String var6); + + boolean CP_Page_DrawRasterImageFromFile(Pointer var1, int var2, int var3, int var4, int var5, String var6, int var7); + + boolean CP_Page_DrawRasterImageFromData(Pointer var1, int var2, int var3, int var4, int var5, byte[] var6, int var7, int var8); + + boolean CP_Page_DrawRasterImageFromPixels(Pointer var1, int var2, int var3, byte[] var4, int var5, int var6, int var7, int var8, int var9, int var10); + + boolean CP_BlackMark_EnableBlackMarkMode(Pointer var1); + + boolean CP_BlackMark_DisableBlackMarkMode(Pointer var1); + + boolean CP_BlackMark_SetBlackMarkMaxFindLength(Pointer var1, int var2); + + boolean CP_BlackMark_FindNextBlackMark(Pointer var1); + + boolean CP_BlackMark_SetBlackMarkPaperPrintPosition(Pointer var1, int var2); + + boolean CP_BlackMark_SetBlackMarkPaperCutPosition(Pointer var1, int var2); + + boolean CP_BlackMark_FullCutBlackMarkPaper(Pointer var1); + + boolean CP_BlackMark_HalfCutBlackMarkPaper(Pointer var1); + + boolean CP_Label_EnableLabelMode(Pointer var1); + + boolean CP_Label_DisableLabelMode(Pointer var1); + + boolean CP_Label_CalibrateLabel(Pointer var1); + + boolean CP_Label_FeedLabel(Pointer var1); + + boolean CP_Label_PageBegin(Pointer var1, int var2, int var3, int var4, int var5, int var6); + + boolean CP_Label_PagePrint(Pointer var1, int var2); + + boolean CP_Label_DrawText(Pointer var1, int var2, int var3, int var4, int var5, String var6); + + boolean CP_Label_DrawTextInUTF8(Pointer var1, int var2, int var3, int var4, int var5, WString var6); + + boolean CP_Label_DrawTextInGBK(Pointer var1, int var2, int var3, int var4, int var5, WString var6); + + boolean CP_Label_DrawBarcode(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, String var9); + + boolean CP_Label_DrawQRCode(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7, String var8); + + boolean CP_Label_DrawPDF417Code(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, String var9); + + boolean CP_Label_DrawImageFromFile(Pointer var1, int var2, int var3, int var4, int var5, String var6, int var7, int var8); + + boolean CP_Label_DrawImageFromData(Pointer var1, int var2, int var3, int var4, int var5, byte[] var6, int var7, int var8, int var9); + + boolean CP_Label_DrawImageFromPixels(Pointer var1, int var2, int var3, byte[] var4, int var5, int var6, int var7, int var8, int var9, int var10, int var11); + + boolean CP_Label_DrawLine(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7); + + boolean CP_Label_DrawRect(Pointer var1, int var2, int var3, int var4, int var5, int var6); + + boolean CP_Label_DrawBox(Pointer var1, int var2, int var3, int var4, int var5, int var6, int var7); + + int CP_Proto_QueryBatteryLevel(Pointer var1, int var2); + + public static class CP_Label_DrawImageFromData_Helper { + public CP_Label_DrawImageFromData_Helper() { + } + + public static boolean DrawImageFromBufferedImage(Pointer handle, int x, int y, int dstw, int dsth, BufferedImage image, int binaryzation_method, int compression_method) { + boolean result = false; + + try { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + ImageIO.write(image, "png", os); + byte[] data = os.toByteArray(); + result = AutoReplyPrint.INSTANCE.CP_Label_DrawImageFromData(handle, x, y, dstw, dsth, data, data.length, binaryzation_method, compression_method); + } catch (Throwable var11) { + var11.printStackTrace(); + } + + return result; + } + } + + public static class CP_Label_TextStyle { + private int style = 0; + + public CP_Label_TextStyle(boolean bold, boolean underline, boolean highlight, boolean strikethrough, int rotation, int widthscale, int heightscale) { + int style = 0; + if (bold) { + style |= 1; + } + + if (underline) { + style |= 2; + } + + if (highlight) { + style |= 4; + } + + if (strikethrough) { + style |= 8; + } + + style |= rotation << 4; + style |= widthscale << 8; + style |= heightscale << 12; + this.style = style; + } + + public int getStyle() { + return this.style; + } + } + + public interface CP_OnBluetoothDeviceDiscovered_Callback extends Callback { + void CP_OnBluetoothDeviceDiscovered(String var1, String var2, Pointer var3); + } + + public interface CP_OnNetPrinterDiscovered_Callback extends Callback { + void CP_OnNetPrinterDiscovered(String var1, String var2, String var3, String var4, Pointer var5); + } + + public interface CP_OnPortClosedEvent_Callback extends Callback { + void CP_OnPortClosedEvent(Pointer var1, Pointer var2); + } + + public interface CP_OnPortOpenFailedEvent_Callback extends Callback { + void CP_OnPortOpenFailedEvent(Pointer var1, String var2, Pointer var3); + } + + public interface CP_OnPortOpenedEvent_Callback extends Callback { + void CP_OnPortOpenedEvent(Pointer var1, String var2, Pointer var3); + } + + public interface CP_OnPortReceivedEvent_Callback extends Callback { + void CP_OnPortReceivedEvent(Pointer var1, Pointer var2, int var3, Pointer var4); + } + + public interface CP_OnPortWrittenEvent_Callback extends Callback { + void CP_OnPortWrittenEvent(Pointer var1, Pointer var2, int var3, Pointer var4); + } + + public interface CP_OnPrinterPrintedEvent_Callback extends Callback { + void CP_OnPrinterPrintedEvent(Pointer var1, int var2, Pointer var3); + } + + public interface CP_OnPrinterReceivedEvent_Callback extends Callback { + void CP_OnPrinterReceivedEvent(Pointer var1, int var2, Pointer var3); + } + + public interface CP_OnPrinterStatusEvent_Callback extends Callback { + void CP_OnPrinterStatusEvent(Pointer var1, long var2, long var4, Pointer var6); + } + + public static class CP_Page_DrawRasterImageFromData_Helper { + public CP_Page_DrawRasterImageFromData_Helper() { + } + + public static boolean DrawRasterImageFromBufferedImage(Pointer handle, int x, int y, int dstw, int dsth, BufferedImage image, int binaryzation_method) { + boolean result = false; + + try { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + ImageIO.write(image, "png", os); + byte[] data = os.toByteArray(); + result = AutoReplyPrint.INSTANCE.CP_Page_DrawRasterImageFromData(handle, x, y, dstw, dsth, data, data.length, binaryzation_method); + } catch (Throwable var10) { + var10.printStackTrace(); + } + + return result; + } + } + + public static class CP_Port_EnumCom_Helper { + public CP_Port_EnumCom_Helper() { + } + + public static String[] EnumCom() { + IntByReference pcbNeeded = new IntByReference(); + AutoReplyPrint.INSTANCE.CP_Port_EnumCom((byte[]) null, 0, pcbNeeded); + if (pcbNeeded.getValue() > 0) { + byte[] pBuf = new byte[pcbNeeded.getValue()]; + if (pBuf != null) { + AutoReplyPrint.INSTANCE.CP_Port_EnumCom(pBuf, pBuf.length, (IntByReference) null); + String s = new String(pBuf); + String[] ss = s.split("\u0000"); + return ss; + } + } + + return null; + } + } + + public static class CP_Port_EnumLpt_Helper { + public CP_Port_EnumLpt_Helper() { + } + + public static String[] EnumLpt() { + IntByReference pcbNeeded = new IntByReference(); + AutoReplyPrint.INSTANCE.CP_Port_EnumLpt((byte[]) null, 0, pcbNeeded); + if (pcbNeeded.getValue() > 0) { + byte[] pBuf = new byte[pcbNeeded.getValue()]; + if (pBuf != null) { + AutoReplyPrint.INSTANCE.CP_Port_EnumLpt(pBuf, pBuf.length, (IntByReference) null); + String s = new String(pBuf); + String[] ss = s.split("\u0000"); + return ss; + } + } + + return null; + } + } + + public static class CP_Port_EnumUsb_Helper { + public CP_Port_EnumUsb_Helper() { + } + + public static String[] EnumUsb() { + IntByReference pcbNeeded = new IntByReference(); + AutoReplyPrint.INSTANCE.CP_Port_EnumUsb((byte[]) null, 0, pcbNeeded); + if (pcbNeeded.getValue() > 0) { + byte[] pBuf = new byte[pcbNeeded.getValue()]; + if (pBuf != null) { + AutoReplyPrint.INSTANCE.CP_Port_EnumUsb(pBuf, pBuf.length, (IntByReference) null); + String s = new String(pBuf); + String[] ss = s.split("\u0000"); + return ss; + } + } + + return null; + } + } + + public static class CP_Pos_PrintRasterImageFromData_Helper { + public CP_Pos_PrintRasterImageFromData_Helper() { + } + + public static boolean PrintRasterImageFromBufferedImage(Pointer handle, int dstw, int dsth, BufferedImage image, int binaryzation_method, int compression_method) { + boolean result = false; + + try { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + ImageIO.write(image, "png", os); + byte[] data = os.toByteArray(); + result = AutoReplyPrint.INSTANCE.CP_Pos_PrintRasterImageFromData(handle, dstw, dsth, data, data.length, binaryzation_method, compression_method); + } catch (Throwable var9) { + var9.printStackTrace(); + } + + return result; + } + } + + public static class CP_PrinterStatus { + private long error_status = 0L; + private long info_status = 0L; + + public CP_PrinterStatus(long error_status, long info_status) { + this.error_status = error_status; + this.info_status = info_status; + } + + public long errorStatus() { + return this.error_status; + } + + public long infoStatus() { + return this.info_status; + } + + public boolean ERROR_OCCURED() { + return this.error_status != 0L; + } + + public boolean ERROR_CUTTER() { + return (this.error_status & 1L) != 0L; + } + + public boolean ERROR_FLASH() { + return (this.error_status & 2L) != 0L; + } + + public boolean ERROR_NOPAPER() { + return (this.error_status & 4L) != 0L; + } + + public boolean ERROR_VOLTAGE() { + return (this.error_status & 8L) != 0L; + } + + public boolean ERROR_MARKER() { + return (this.error_status & 16L) != 0L; + } + + public boolean ERROR_ENGINE() { + return (this.error_status & 32L) != 0L; + } + + public boolean ERROR_OVERHEAT() { + return (this.error_status & 64L) != 0L; + } + + public boolean ERROR_COVERUP() { + return (this.error_status & 128L) != 0L; + } + + public boolean ERROR_MOTOR() { + return (this.error_status & 256L) != 0L; + } + + public boolean INFO_LABELPAPER() { + return (this.info_status & 2L) != 0L; + } + + public boolean INFO_LABELMODE() { + return (this.info_status & 4L) != 0L; + } + + public boolean INFO_HAVEDATA() { + return (this.info_status & 8L) != 0L; + } + + public boolean INFO_NOPAPERCANCELED() { + return (this.info_status & 16L) != 0L; + } + + public boolean INFO_PAPERNOFETCH() { + return (this.info_status & 32L) != 0L; + } + + public boolean INFO_PRINTIDLE() { + return (this.info_status & 64L) != 0L; + } + + public boolean INFO_RECVIDLE() { + return (this.info_status & 128L) != 0L; + } + } + + public static class CP_Printer_GetPrinterFirmwareVersion_Helper { + public CP_Printer_GetPrinterFirmwareVersion_Helper() { + } + + public static String GetPrinterFirmwareVersion(Pointer handle) { + IntByReference pcbNeeded = new IntByReference(); + AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterFirmwareVersion(handle, (byte[]) null, 0, pcbNeeded); + if (pcbNeeded.getValue() > 0) { + byte[] pBuf = new byte[pcbNeeded.getValue()]; + if (pBuf != null) { + AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterFirmwareVersion(handle, pBuf, pBuf.length, (IntByReference) null); + String s = new String(pBuf); + return s; + } + } + + return null; + } + } + + public static class CP_RTSTATUS_Helper { + public CP_RTSTATUS_Helper() { + } + + public static boolean CP_RTSTATUS_DRAWER_OPENED(long status) { + return (status >> 0 & 4L) == 0L; + } + + public static boolean CP_RTSTATUS_OFFLINE(long status) { + return (status >> 0 & 8L) == 8L; + } + + public static boolean CP_RTSTATUS_COVERUP(long status) { + return (status >> 8 & 4L) == 4L; + } + + public static boolean CP_RTSTATUS_FEED_PRESSED(long status) { + return (status >> 8 & 8L) == 8L; + } + + public static boolean CP_RTSTATUS_NOPAPER(long status) { + return (status >> 8 & 32L) == 32L; + } + + public static boolean CP_RTSTATUS_ERROR_OCCURED(long status) { + return (status >> 8 & 64L) == 64L; + } + + public static boolean CP_RTSTATUS_CUTTER_ERROR(long status) { + return (status >> 16 & 8L) == 8L; + } + + public static boolean CP_RTSTATUS_UNRECOVERABLE_ERROR(long status) { + return (status >> 16 & 32L) == 32L; + } + + public static boolean CP_RTSTATUS_DEGREE_OR_VOLTAGE_OVERRANGE(long status) { + return (status >> 16 & 64L) == 64L; + } + + public static boolean CP_RTSTATUS_PAPER_NEAREND(long status) { + return (status >> 24 & 12L) == 12L; + } + + public static boolean CP_RTSTATUS_PAPER_TAKEOUT(long status) { + return (status >> 24 & 4L) == 4L; + } + } + + public static class GetLibraryPath_Helper { + public GetLibraryPath_Helper() { + } + + private static String GetLibraryPath() { + if (Platform.isWindows()) { + return Platform.is64Bit() ? "/autoreplyprint/win64/autoreplyprint.dll" : "/autoreplyprint/win32/autoreplyprint.dll"; + } else if (Platform.isLinux()) { + return Platform.is64Bit() ? "/autoreplyprint/linux-x64/libautoreplyprint.so" : "/autoreplyprint/linux-x86/libautoreplyprint.so"; + } else { + return Platform.isMac() ? "/autoreplyprint/mac/libautoreplyprint.so" : "autoreplyprint"; + } + } + } +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/utils/AutoReplyPrint2.java b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/AutoReplyPrint2.java new file mode 100644 index 0000000..c7f72cb --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/AutoReplyPrint2.java @@ -0,0 +1,60 @@ +package com.dpkj.modules.autoReplyPrint.utils; + +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Platform; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class AutoReplyPrint2 { + + + public static AutoReplyPrint2Sdk getAutoReplyPrint2SDK() throws AutoReplyPrint2RegistrationException { + try { + return Native.load(GetLibraryPath_Helper.GetLibraryPath(), AutoReplyPrint2Sdk.class); + } catch (UnsatisfiedLinkError e) { + log.info("[AutoReplyPrint2][AutoReplyPrint2.getAutoReplyPrint2SDK] SDK注册失败 {}", e.getMessage()); + throw new AutoReplyPrint2RegistrationException("Failed to load AutoReplyPrint2Sdk library: ", e); + } + } + + + /** + * 定义接口映射本地库中的函数。 + */ + public interface AutoReplyPrint2Sdk extends Library { + /** + * 获取打印机固件版本 + * @return + */ + String CPPrinterGetPrinterFirmwareVersion(); + } + + /** + * 定义自定义异常类,用于表示注册控件时发生的错误 + */ + public static class AutoReplyPrint2RegistrationException extends Exception { + public AutoReplyPrint2RegistrationException(String message) { + super(message); + } + + public AutoReplyPrint2RegistrationException(String message, Throwable cause) { + super(message, cause); + } + } + + public static class GetLibraryPath_Helper { + public GetLibraryPath_Helper() { + } + + private static String GetLibraryPath() { + if (Platform.isWindows()) { + return Platform.is64Bit() ? "/autoreplyprint/win64/autoreplyprint.dll" : "/autoreplyprint/win32/autoreplyprint.dll"; + } else if (Platform.isLinux()) { + return Platform.is64Bit() ? "/autoreplyprint/linux-x64/libautoreplyprint.so" : "/autoreplyprint/linux-x86/libautoreplyprint.so"; + } else { + return Platform.isMac() ? "/autoreplyprint/mac/libautoreplyprint.so" : "autoreplyprint"; + } + } + } +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/utils/MyLibrary.java b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/MyLibrary.java new file mode 100644 index 0000000..64fbe3d --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/MyLibrary.java @@ -0,0 +1,11 @@ +package com.dpkj.modules.autoReplyPrint.utils; + +import com.sun.jna.Native; +import com.sun.jna.win32.StdCallLibrary; + +public interface MyLibrary extends StdCallLibrary { + MyLibrary INSTANCE = (MyLibrary) Native.load("D:\\DPKJ\\yinyitong-zhongyuyuan-dll\\src\\main\\resources\\autoreplyprint\\win64\\autoreplyprint.dll", MyLibrary.class); + + // 映射DLL中的函数 + String CP_Printer_GetPrinterFirmwareVersion(); +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/utils/MyNativeClass.java b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/MyNativeClass.java new file mode 100644 index 0000000..5bfed8d --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/MyNativeClass.java @@ -0,0 +1,13 @@ +package com.dpkj.modules.autoReplyPrint.utils; + +public class MyNativeClass { + public static native void ICC_Reader_Open(String devName); + + static { + System.load("D:\\DPKJ\\yinyitong-zhongyuyuan-dll\\src\\main\\resources\\win32-x86\\UnPack.dll"); + } + + public static void main(String[] args) { + ICC_Reader_Open("USB1"); + } +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/utils/TestFunction.java b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/TestFunction.java new file mode 100644 index 0000000..a66276f --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/TestFunction.java @@ -0,0 +1,1775 @@ +package com.dpkj.modules.autoReplyPrint.utils; + +import com.sun.jna.Pointer; +import com.sun.jna.WString; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.FileInputStream; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class TestFunction { + + void Test_Pos_SampleTicket_58MM_1(Pointer h) { + int paperWidth = 384; + + AutoReplyPrint.INSTANCE.CP_Pos_ResetPrinter(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "123xxstreet,xxxcity,xxxxstate\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_Right); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "TEL 9999-99-9999 C#2\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_HCenter); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "yyyy-MM-dd HH:mm:ss"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "apples"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 6); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$10.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "grapes"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 6); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$20.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "bananas"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 6); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$30.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "lemons"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 6); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$40.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "oranges"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 7); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$100.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "Before adding tax"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 7); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$200.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "tax 5.0%"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 6); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$10.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + String line = ""; + for (int i = 0; i < paperWidth / 12; ++i) + line += " "; + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUnderline(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, line); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUnderline(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 1, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "total"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 2 * 7); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$190.00"); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 0); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "Customer's payment"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 7); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$200.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "Change"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, paperWidth - 12 * 6); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "$10.00"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 3); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_BelowBarcode); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_UPCA, "12345678901"); + + AutoReplyPrint.INSTANCE.CP_Pos_Beep(h, 1, 500); + + { + Test_Pos_QueryPrintResult(h); + } + } + + void Test_Pos_SampleTicket_80MM_1(Pointer h) { + int[] nLineStartPos = {0, 201, 401}; + int[] nLineEndPos = {200, 400, 575}; + + { + AutoReplyPrint.INSTANCE.CP_Pos_ResetPrinter(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 2); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_Right); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("服务台\r\n")); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 2); + + int nStartPos = 0; + int nEndPos = 120; + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLineSpecifyThickness(h, nStartPos, nEndPos, 3); + AutoReplyPrint.INSTANCE.CP_Pos_FeedDot(h, 10); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_Left); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextBold(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 1, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 12); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("圆桌")); + AutoReplyPrint.INSTANCE.CP_Pos_FeedDot(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 0); + AutoReplyPrint.INSTANCE.CP_Pos_FeedDot(h, 10); + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLineSpecifyThickness(h, nStartPos, nEndPos, 3); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextBold(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("麻辣香锅(上梅林店)\r\n2018年2月7日15:51:00\r\n\r\n")); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_HCenter); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 1, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("\r\n15-D-一楼-大厅-散座\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_Left); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("\r\n扫码点餐订单\r\n店内用餐\r\n7人\r\n")); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("\r\n热菜类\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 80); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("鱼香肉丝")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 200); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("1")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 480); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("¥23.50\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 80); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("麻辣鸡丝")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 200); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("1")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 480); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("¥23.50\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 0); + + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("凉菜类\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 80); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("凉拌腐竹")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 200); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("1")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 480); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("¥23.50\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 80); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("糖醋花生")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 200); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("1")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 480); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("¥23.50\r\n")); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_FeedDot(h, 30); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 80); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("消毒餐具")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 200); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("7")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 480); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("¥14.00\r\n")); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("在线支付")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 480); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("¥114.00\r\n")); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("备注\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintAreaLeftMargin(h, 80); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("所有菜都不要放葱,口味要微辣。百事可乐不要加冰。上菜快点,太慢了!!\r\n\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintAreaLeftMargin(h, 0); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_HCenter); + AutoReplyPrint.INSTANCE.CP_Pos_PrintQRCode(h, 0, AutoReplyPrint.CP_QRCodeECC_L, "麻辣香锅"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("\r\n用心服务每一天\r\n40008083030\r\n\r\n")); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, nLineStartPos.length, nLineStartPos, nLineEndPos); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_Beep(h, 3, 300); + AutoReplyPrint.INSTANCE.CP_Pos_FeedAndHalfCutPaper(h); + } + + { + Test_Pos_QueryPrintResult(h); + } + } + + void Test_Pos_SampleTicket_80MM_2(Pointer h) { + { + AutoReplyPrint.INSTANCE.CP_Printer_ClearPrinterBuffer(h); + AutoReplyPrint.INSTANCE.CP_Pos_ResetPrinter(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, 0, 575); + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, 0, 575); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_Left); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextBold(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("国药堂大药房(上海)限公司\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("测试自动售药机器\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("订单号:" + 999999999 + "\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("日期:" + "2019-07-31" + "\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, 0, 575); + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, 0, 575); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("商品编码/商品名称/规格/厂家\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, 0, 575); + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, 0, 575); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_QueryPrintResult(h, 3000); + } + + { + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("FM111111" + "/" + "藿香正气水" + "/" + "1.8g*16片" + "/" + "盒" + "/" + "999感冒灵修正药业" + "★运动员慎用" + "\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("数量" + 666)); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 240); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("单价:" + 111)); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 380); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("金额:" + "9999.99" + "\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("批号:" + "22222222")); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 340); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("有效期至:" + "2020-22-22" + "\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, 0, 575); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("数量合计:" + 999999)); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 380); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("金额合计:" + 9999.99 + "\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_Left); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("客服电话:4001-005-835\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_HCenter); + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintAreaLeftMargin(h, 20); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("因药品属于特殊商品,除药品质量原因外,药品一经售出,不得退换\r\n\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintAreaLeftMargin(h, 20); + + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_HCenter); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 8); + AutoReplyPrint.INSTANCE.CP_Pos_PrintQRCode(h, 0, AutoReplyPrint.CP_QRCodeECC_L, "https://m.yao123.com/static/hmkp/invoiceInfo.html"); + + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("盒马APP-我的-扫码-申请开发票。\r\n请在90天内申请开发票\r\n\r\n\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_FeedAndHalfCutPaper(h); + + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 1); + } + + { + Test_Pos_QueryPrintResult(h); + } + } + + void Test_Label_SampleTicket_58MM_1(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 240, 0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 240, 1, 1); + AutoReplyPrint.INSTANCE.CP_Label_DrawTextInUTF8(h, 10, 10, 24, 0, new WString("型号:P58A+")); + AutoReplyPrint.INSTANCE.CP_Label_DrawTextInUTF8(h, 10, 40, 24, 0, new WString("MFG :00")); + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 70, AutoReplyPrint.CP_Label_BarcodeType_CODE128, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, 0, "No.123456"); + AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + + { + Test_Pos_QueryPrintResult(h); + } + } + + void Test_Label_SampleTicket_80MM_1(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 576, 240, 0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 576, 240, 1, 1); + AutoReplyPrint.INSTANCE.CP_Label_DrawTextInUTF8(h, 10, 10, 24, 0, new WString("型号:P58A+")); + AutoReplyPrint.INSTANCE.CP_Label_DrawTextInUTF8(h, 10, 40, 24, 0, new WString("MFG :00")); + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 70, AutoReplyPrint.CP_Label_BarcodeType_CODE128, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, 0, "No.123456"); + AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + + { + Test_Pos_QueryPrintResult(h); + } + } + + void Test_Page_SampleTicket_58MM_1(Pointer h) { + int paperWidth = 384; + int paperHeight = 800; + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, paperWidth, paperHeight); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 1, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, AutoReplyPrint.CP_Page_DrawAlignment_HCenter, 10, new WString("中国福利彩票")); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 0); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, 60, new WString("销售期2015033")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, AutoReplyPrint.CP_Page_DrawAlignment_Right, 60, new WString("兑奖期2015033")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, 90, new WString("站号230902001")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, AutoReplyPrint.CP_Page_DrawAlignment_Right, 90, new WString("7639-A")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, 120, new WString("注数5")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, AutoReplyPrint.CP_Page_DrawAlignment_Right, 120, new WString("金额10.00")); + + AutoReplyPrint.INSTANCE.CP_Pos_SetTextLineHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUnderline(h, 2); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, 160, new WString(" A: 02 07 10 17 20 21 25\r\n A: 02 07 10 17 20 21 25\r\n A: 02 07 10 17 20 21 25\r\n A: 02 07 10 17 20 21 25\r\n A: 02 07 10 17 20 21 25\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUnderline(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextLineHeight(h, 30); + + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 3); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_BelowBarcode); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 460, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, "1234567890"); + AutoReplyPrint.INSTANCE.CP_Page_DrawQRCode(h, 284, 460, 0, AutoReplyPrint.CP_QRCodeECC_L, "1234567890"); + + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + AutoReplyPrint.INSTANCE.CP_Pos_FeedAndHalfCutPaper(h); + AutoReplyPrint.INSTANCE.CP_Pos_KickOutDrawer(h, 0, 100, 100); + AutoReplyPrint.INSTANCE.CP_Pos_KickOutDrawer(h, 1, 100, 100); + AutoReplyPrint.INSTANCE.CP_Pos_Beep(h, 1, 500); + + { + Test_Pos_QueryPrintResult(h); + } + } + + void Test_Page_SampleTicket_80MM_1(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 576, 200); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 1, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawText(h, AutoReplyPrint.CP_Page_DrawAlignment_HCenter, 0, "Print Store"); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 7, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawText(h, AutoReplyPrint.CP_Page_DrawAlignment_HCenter, 48, "______"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, AutoReplyPrint.CP_Page_DrawAlignment_HCenter, 100, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, "No.201804190001"); + + AutoReplyPrint.INSTANCE.CP_Page_SetPageArea(h, 0, 200, 576, 1400); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 576, 1400, 1, 1); + AutoReplyPrint.INSTANCE.CP_Page_SetPageDrawDirection(h, AutoReplyPrint.CP_Page_DrawDirection_TopToBottom); + + int y = 0; + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 1, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, AutoReplyPrint.CP_Page_DrawAlignment_HCenter, y, new WString("Print物流(测试)托运单")); + + y += 64; + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 0); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("发站:厦门总部")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 300, y, new WString("到站:广州 0539-7825336")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 600, y, new WString("托运日期:2016-05-24")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 900, y, new WString("运单号:601052400032")); + + y += 32; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("收货人")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 300, y, new WString("电话:15000353189")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 600, y, new WString("运费:提付10")); + + y += 32; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("发货人")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 300, y, new WString("电话:15000353189")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 600, y, new WString("会员号")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 900, y, new WString("代收款:1000")); + + y += 32; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("货物名称")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 150, y, new WString("件数")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 300, y, new WString("重量")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 450, y, new WString("体积")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 600, y, new WString("保价额")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 750, y, new WString("保价费")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 900, y, new WString("交货方式")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 1050, y, new WString("自提")); + + y += 32; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("配件")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 900, y, new WString("送货费")); + + y += 32; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("托运地址")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 150, y, new WString("运河路高架桥南张营中心街东首")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 900, y, new WString("预付运费")); + + y += 32; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("到站地址")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 150, y, new WString("金兰物流E7区11号")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 900, y, new WString("提付合计")); + + y += 32; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("备注")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 900, y, new WString("返款")); + + y += 32; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("声明:1、不得虚假报货名 2、不得虚假报货名 3、不得虚假报货名 4、不得虚假报货名 5、不得虚假报货名 6、不得虚假报货名 7、不得虚假报货名 8、不得虚假报货名 1、不得虚假报货名 2、不得虚假报货名 3、不得虚假报货名 4、不得虚假报货名 5、不得虚假报货名 6、不得虚假报货名 7、不得虚假报货名 8、不得虚假报货名 1、不得虚假报货名 2、不得虚假报货名 3、不得虚假报货名 4、不得虚假报货名 5、不得虚假报货名 6、不得虚假报货名 7、不得虚假报货名 8、不得虚假报货名 1、不得虚假报货名 2、不得虚假报货名 3、不得虚假报货名 4、不得虚假报货名 5、不得虚假报货名 6、不得虚假报货名 7、不得虚假报货名 8、不得虚假报货名")); + + y = 530; + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 0, y - 5, 1400, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, y, new WString("服务查询:2379911")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 300, y, new WString("发货人签名")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 600, y, new WString("第一联")); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 900, y, new WString("制单")); + + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + AutoReplyPrint.INSTANCE.CP_Pos_KickOutDrawer(h, 0, 100, 100); + AutoReplyPrint.INSTANCE.CP_Pos_KickOutDrawer(h, 1, 100, 100); + AutoReplyPrint.INSTANCE.CP_Pos_Beep(h, 1, 500); + AutoReplyPrint.INSTANCE.CP_Pos_FeedAndHalfCutPaper(h); + + { + Test_Pos_QueryPrintResult(h); + } + } + + void Test_Port_Write(Pointer h) { + byte cmd[] = {0x12, 0x54}; + if (AutoReplyPrint.INSTANCE.CP_Port_Write(h, cmd, cmd.length, 1000) != cmd.length) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Port_Read(Pointer h) { + // send this cmd to query printer status + byte cmd[] = {0x10, 0x04, 0x01}; + AutoReplyPrint.INSTANCE.CP_Port_SkipAvailable(h); + if (AutoReplyPrint.INSTANCE.CP_Port_Write(h, cmd, cmd.length, 1000) == cmd.length) { + byte status[] = new byte[1]; + if (AutoReplyPrint.INSTANCE.CP_Port_Read(h, status, 1, 2000) == 1) { + TestUtils.showMessageOnUiThread(String.format("Status 0x%02X", status[0] & 0xff)); + } else { + TestUtils.showMessageOnUiThread("Read failed"); + } + } else { + TestUtils.showMessageOnUiThread("Write failed"); + } + } + + void Test_Port_ReadUntilByte(Pointer h) { + // send this cmd to query printer status + byte cmd[] = {0x1F, 0x28, 0x4C, 0x02, 0x00, 0x72, 0x41}; + AutoReplyPrint.INSTANCE.CP_Port_SkipAvailable(h); + if (AutoReplyPrint.INSTANCE.CP_Port_Write(h, cmd, cmd.length, 1000) == cmd.length) { + byte buffer[] = new byte[0x100]; + int nBytesReaded = AutoReplyPrint.INSTANCE.CP_Port_ReadUntilByte(h, buffer, buffer.length, 2000, (byte) 0x00); + if (nBytesReaded > 0) { + TestUtils.showMessageOnUiThread(new String(buffer)); + } else { + TestUtils.showMessageOnUiThread("Read failed"); + } + } else { + TestUtils.showMessageOnUiThread("Write failed"); + } + } + + void Test_Port_Available(Pointer h) { + int available = AutoReplyPrint.INSTANCE.CP_Port_Available(h); + TestUtils.showMessageOnUiThread("available " + available); + } + + void Test_Port_SkipAvailable(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Port_SkipAvailable(h); + } + + void Test_Port_IsConnectionValid(Pointer h) { + boolean valid = AutoReplyPrint.INSTANCE.CP_Port_IsConnectionValid(h); + TestUtils.showMessageOnUiThread("valid " + valid); + } + + void Test_Printer_GetPrinterInfo(Pointer h) { + String firmware_version = AutoReplyPrint.CP_Printer_GetPrinterFirmwareVersion_Helper.GetPrinterFirmwareVersion(h) + "\r\n"; + IntByReference width_mm = new IntByReference(); + IntByReference height_mm = new IntByReference(); + IntByReference dots_per_mm = new IntByReference(); + LongByReference printer_error_status = new LongByReference(); + LongByReference printer_info_status = new LongByReference(); + IntByReference printer_received_byte_count = new IntByReference(); + IntByReference printer_printed_page_id = new IntByReference(); + LongByReference timestamp_ms_printer_status = new LongByReference(); + LongByReference timestamp_ms_printer_received = new LongByReference(); + LongByReference timestamp_ms_printer_printed = new LongByReference(); + if (AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterResolutionInfo(h, width_mm, height_mm, dots_per_mm) && + AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterStatusInfo(h, printer_error_status, printer_info_status, timestamp_ms_printer_status) && + AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterReceivedInfo(h, printer_received_byte_count, timestamp_ms_printer_received) && + AutoReplyPrint.INSTANCE.CP_Printer_GetPrinterPrintedInfo(h, printer_printed_page_id, timestamp_ms_printer_printed)) { + Date dt_printer_status = new Date(timestamp_ms_printer_status.getValue()); + Date dt_printer_received = new Date(timestamp_ms_printer_received.getValue()); + Date dt_printer_printed = new Date(timestamp_ms_printer_printed.getValue()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String str_printer_resolution = "Width: " + width_mm.getValue() + " Height: " + height_mm.getValue() + " DotsPerMM: " + dots_per_mm.getValue() + "\r\n"; + String str_printer_error_status = simpleDateFormat.format(dt_printer_status) + String.format(" Printer Error Status: 0x%04X\r\n", printer_error_status.getValue() & 0xffff); + String str_printer_info_status = simpleDateFormat.format(dt_printer_status) + String.format(" Printer Info Status: 0x%04X\r\n", printer_info_status.getValue() & 0xffff); + String str_printer_received = simpleDateFormat.format(dt_printer_received) + String.format(" Printer Received Byte Count: %d\r\n", printer_received_byte_count.getValue()); + String str_printer_printed = simpleDateFormat.format(dt_printer_printed) + String.format(" Printer Printed Page ID: %d\r\n", printer_printed_page_id.getValue()); + TestUtils.showMessageOnUiThread(firmware_version + str_printer_resolution + str_printer_error_status + str_printer_info_status + str_printer_received + str_printer_printed); + } + } + + void Test_Printer_ClearPrinterBuffer(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Printer_ClearPrinterBuffer(h); + } + + void Test_Printer_ClearPrinterError(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Printer_ClearPrinterError(h); + } + + void Test_Pos_QueryRTStatus(Pointer h) { + int status = AutoReplyPrint.INSTANCE.CP_Pos_QueryRTStatus(h, 3000); + if (status != 0) { + String s = ""; + s += String.format("RTStatus: %02x %02x %02x %02x\r\n", status & 0xff, (status >> 8) & 0xff, (status >> 16) & 0xff, (status >> 24) & 0xff); + if (AutoReplyPrint.CP_RTSTATUS_Helper.CP_RTSTATUS_COVERUP(status)) + s += "[Cover Up]"; + if (AutoReplyPrint.CP_RTSTATUS_Helper.CP_RTSTATUS_NOPAPER(status)) + s += "[No Paper]"; + TestUtils.showMessageOnUiThread(s); + } else { + TestUtils.showMessageOnUiThread("Query failed"); + } + } + + void Test_Pos_QueryPrintResult(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_QueryPrintResult(h, 30000); + if (!result) + TestUtils.showMessageOnUiThread("Print failed"); + else + TestUtils.showMessageOnUiThread("Print Success"); + } + + void Test_Pos_KickOutDrawer(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_KickOutDrawer(h, 0, 100, 100); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_KickOutDrawer(h, 1, 100, 100); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_Beep(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_Beep(h, 3, 300); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_FeedAndHalfCutPaper(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedAndHalfCutPaper(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_FullCutPaper(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FullCutPaper(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_HalfCutPaper(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_HalfCutPaper(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_Feed(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "12345678901234567890"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 4); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "12345678901234567890"); + AutoReplyPrint.INSTANCE.CP_Pos_FeedDot(h, 100); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintSelfTestPage(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintSelfTestPage(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintText(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "12345678901234567890\r\n"); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintTextInUTF8(Pointer h) { + WString str = new WString( + "1234567890\r\n" + + "abcdefghijklmnopqrstuvwxyz\r\n" + + "ΑΒΓΔΕΖΗΘΙΚ∧ΜΝΞΟ∏Ρ∑ΤΥΦΧΨΩ\r\n" + + "αβγδεζηθικλμνξοπρστυφχψω\r\n" + + "你好,欢迎使用!\r\n" + + "你號,歡迎使用!\r\n" + + "梦を见る事が出来なければ\r\n未来を変える事は出来ません\r\n" + + "왕관을 쓰려는자\r\n그 무게를 견뎌라\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, str); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintTextInGBK(Pointer h) { + WString str = new WString("1234567890\r\nabcdefghijklmnopqrstuvwxyz\r\n你好,欢迎使用!\r\n你號,歡迎使用!\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_GBK); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInGBK(h, str); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintTextInBIG5(Pointer h) { + WString str = new WString("1234567890\r\nabcdefghijklmnopqrstuvwxyz\r\n你號,歡迎使用!\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_BIG5); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInBIG5(h, str); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintTextInShiftJIS(Pointer h) { + WString str = new WString( + "1234567890\r\n" + + "abcdefghijklmnopqrstuvwxyz\r\n" + + "こんにちは\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_ShiftJIS); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInShiftJIS(h, str); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintTextInEUCKR(Pointer h) { + WString str = new WString( + "1234567890\r\n" + + "abcdefghijklmnopqrstuvwxyz\r\n" + + "왕관을 쓰려는자\r\n" + + "그 무게를 견뎌라\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_EUCKR); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInEUCKR(h, str); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintBarcode(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextFontType(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_BelowBarcode); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_UPCA, "01234567890"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_UPCE, "123456"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_EAN13, "123456789012"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_EAN8, "1234567"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_CODE39, "123456"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_ITF, "123456"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_CODEBAR, "A123456A"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_CODE93, "123456"); + AutoReplyPrint.INSTANCE.CP_Pos_PrintBarcode(h, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, "No.123456"); + + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintQRCode(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 8); + AutoReplyPrint.INSTANCE.CP_Pos_PrintQRCode(h, 0, AutoReplyPrint.CP_QRCodeECC_L, "Hello 欢迎使用"); + + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + + } + + void Test_Pos_PrintQRCodeUseEpsonCmd(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_PrintQRCodeUseEpsonCmd(h, 8, AutoReplyPrint.CP_QRCodeECC_L, "Hello 欢迎使用"); + + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + + } + + void Test_Pos_PrintDoubleQRCode(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_PrintDoubleQRCode(h, 4, 0, 4, AutoReplyPrint.CP_QRCodeECC_L, "hello", 200, 3, AutoReplyPrint.CP_QRCodeECC_L, "test"); + + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + + } + + void Test_Pos_PrintPDF417BarcodeUseEpsonCmd(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_PrintPDF417BarcodeUseEpsonCmd(h, 0, 0, 3, 3, 0, 0, "test 测试"); + + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + + } + + void Test_Pos_PrintRasterImageFromBufferedImage(Pointer h) { + BufferedImage image = null; + try { + image = ImageIO.read(new FileInputStream("images/yellowmen.png")); + } catch (Throwable tr) { + tr.printStackTrace(); + } + if ((image == null) || (image.getWidth() == 0) || (image.getHeight() == 0)) + return; + + int printwidth = 384; + int dstw = printwidth; + int dsth = (int) (dstw * ((double) image.getHeight() / image.getWidth())); + + boolean result = AutoReplyPrint.CP_Pos_PrintRasterImageFromData_Helper.PrintRasterImageFromBufferedImage(h, dstw, dsth, image, AutoReplyPrint.CP_ImageBinarizationMethod_ErrorDiffusion, AutoReplyPrint.CP_ImageCompressionMethod_None); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintHorizontalLine(Pointer h) { + for (int i = 0; i < 50; i += 1) + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, i, i + 100); + for (int i = 50; i > 0; i -= 1) + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLine(h, i, i + 100); + + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintHorizontalLineSpecifyThickness(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_PrintHorizontalLineSpecifyThickness(h, 0, 200, 10); + + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_PrintMultipleHorizontalLinesAtOneRow(Pointer h) { + int r = 150; + for (int y = -r; y <= r; ++y) { + int x = (int) Math.sqrt(r * r - y * y); + int x1 = -x + r; + int x2 = x + r; + int[] pLineStartPosition = new int[]{x1, x2}; + int[] pLineEndPosition = new int[]{x1, x2}; + if (AutoReplyPrint.INSTANCE.CP_Pos_PrintMultipleHorizontalLinesAtOneRow(h, 2, pLineStartPosition, pLineEndPosition)) + continue; + else + break; + } + + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetMovementUnit(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetMovementUnit(h, 100, 100); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextCharRightSpacing(h, 10); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "1234567890\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetMovementUnit(h, 200, 200); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextCharRightSpacing(h, 10); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "1234567890\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextCharRightSpacing(h, 0); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintAreaLeftMargin(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintAreaLeftMargin(h, 96); + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintAreaWidth(h, 384); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "1234567890123456789012345678901234567890\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_ResetPrinter(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintAreaWidth(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintAreaWidth(h, 384); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "1234567890123456789012345678901234567890\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_ResetPrinter(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintPosition(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "12345678901234567890\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, 24); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "1234567890"); + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalRelativePrintPosition(h, 24); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "1234567890\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetAlignment(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_Right); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "12345678901234567890\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_HCenter); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "12345678901234567890\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAlignment(h, AutoReplyPrint.CP_Pos_Alignment_Left); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "12345678901234567890\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetTextScale(Pointer h) { + int nPosition = 0; + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, nPosition); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "a"); + nPosition += 12; + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, nPosition); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 1, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "a"); + nPosition += 12 * 2; + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, nPosition); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 2, 2); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "a"); + nPosition += 12 * 3; + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, nPosition); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 3, 3); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "a"); + nPosition += 12 * 4; + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, nPosition); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 4, 4); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "a"); + nPosition += 12 * 5; + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, nPosition); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 5, 5); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "a"); + nPosition += 12 * 6; + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, nPosition); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 6, 6); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "a"); + nPosition += 12 * 7; + AutoReplyPrint.INSTANCE.CP_Pos_SetHorizontalAbsolutePrintPosition(h, nPosition); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 7, 7); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "a"); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextScale(h, 0, 0); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetAsciiTextFontType(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextFontType(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "FontA\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextFontType(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "FontB\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextFontType(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "FontC\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextFontType(h, 3); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "FontD\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextFontType(h, 4); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "FontE\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextFontType(h, 0); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetTextBold(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetTextBold(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("粗体 Bold\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextBold(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "Normal\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetTextUnderline(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUnderline(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("下划线2点 Underline2\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUnderline(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("下划线1点 Underline2\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUnderline(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("无下划线 No Underline\r\n")); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetTextUpsideDown(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUpsideDown(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("上下倒置 UpsideDown\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextUpsideDown(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "Normal\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetTextWhiteOnBlack(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextWhiteOnBlack(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("黑白反显 WhiteOnBlack\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextWhiteOnBlack(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "Normal\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetTextRotate(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextRotate(h, 1); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, new WString("文字旋转打印 TextRotate\r\n")); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextRotate(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "Normal\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetTextLineHeight(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetTextLineHeight(h, 100); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "LineHeight 100\r\nLineHeight 100\r\nLineHeight 100\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetTextLineHeight(h, 32); + AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "LineHeight 32\r\nLineHeight 32\r\nLineHeight 32\r\n"); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetAsciiTextCharRightSpacing(Pointer h) { + WString str = new WString("Hello你好\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextCharRightSpacing(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, str); + AutoReplyPrint.INSTANCE.CP_Pos_SetAsciiTextCharRightSpacing(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, str); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetKanjiTextCharSpacing(Pointer h) { + WString str = new WString("Hello你好\r\n"); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + AutoReplyPrint.INSTANCE.CP_Pos_SetKanjiTextCharSpacing(h, 2, 2); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, str); + AutoReplyPrint.INSTANCE.CP_Pos_SetKanjiTextCharSpacing(h, 0, 0); + AutoReplyPrint.INSTANCE.CP_Pos_PrintTextInUTF8(h, str); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_FeedLine(h, 3); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_ResetPrinter(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_ResetPrinter(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintSpeed_20(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintSpeed(h, 20); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintSelfTestPage(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintSpeed_50(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintSpeed(h, 50); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintSelfTestPage(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintSpeed_100(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintSpeed(h, 100); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintSelfTestPage(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintDensity_0(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintDensity(h, 0); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintSelfTestPage(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintDensity_7(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintDensity(h, 7); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintSelfTestPage(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetPrintDensity_15(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Pos_SetPrintDensity(h, 15); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintSelfTestPage(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetSingleByteMode(Pointer h) { + String str = "Welcome 你好\r\n"; + + AutoReplyPrint.INSTANCE.CP_Pos_SetSingleByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetCharacterSet(h, AutoReplyPrint.CP_CharacterSet_CHINA); + AutoReplyPrint.INSTANCE.CP_Pos_SetCharacterCodepage(h, AutoReplyPrint.CP_CharacterCodepage_CP437); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, str); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Pos_SetMultiByteMode(Pointer h) { + String str = "Welcome 你好\r\n"; + + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, str); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_SetPageDrawDirection(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_SetPageDrawDirection(h, AutoReplyPrint.CP_Page_DrawDirection_LeftToRight); + AutoReplyPrint.INSTANCE.CP_Page_DrawText(h, 0, 0, "LeftToRight"); + AutoReplyPrint.INSTANCE.CP_Page_SetPageDrawDirection(h, AutoReplyPrint.CP_Page_DrawDirection_RightToLeft); + AutoReplyPrint.INSTANCE.CP_Page_DrawText(h, 0, 0, "RightToLeft"); + AutoReplyPrint.INSTANCE.CP_Page_SetPageDrawDirection(h, AutoReplyPrint.CP_Page_DrawDirection_TopToBottom); + AutoReplyPrint.INSTANCE.CP_Page_DrawText(h, 0, 0, "TopToBottom"); + AutoReplyPrint.INSTANCE.CP_Page_SetPageDrawDirection(h, AutoReplyPrint.CP_Page_DrawDirection_BottomToTop); + AutoReplyPrint.INSTANCE.CP_Page_DrawText(h, 0, 0, "BottomToTop"); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + boolean result = AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_DrawRect(Pointer h) { + // 10,10 + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 10, 10, 100, 100, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, 20, 20, 80, 80, 0); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // left,top + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -1, -1, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // left,vcenter + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -1, -2, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // left,bottom + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -1, -3, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // hcenter,top + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -2, -1, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // hcenter,vcenter + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -2, -2, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // hcenter,bottom + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -2, -3, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // right,top + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -3, -1, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // right,vcenter + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -3, -2, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + // right,bottom + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawRect(h, -3, -3, 100, 20, 1); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + } + + void Test_Page_DrawText(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawText(h, 0, 0, "12345678901234567890"); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + boolean result = AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_DrawTextInUTF8(Pointer h) { + WString str = new WString( + "1234567890\r\n" + + "abcdefghijklmnopqrstuvwxyz\r\n" + + "ΑΒΓΔΕΖΗΘΙΚ∧ΜΝΞΟ∏Ρ∑ΤΥΦΧΨΩ\r\n" + + "αβγδεζηθικλμνξοπρστυφχψω\r\n" + + "你好,欢迎使用!\r\n" + + "你號,歡迎使用!\r\n" + + "梦を见る事が出来なければ\r\n未来を変える事は出来ません\r\n" + + "왕관을 쓰려는자\r\n그 무게를 견뎌라\r\n"); + + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_UTF8); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInUTF8(h, 0, 0, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + boolean result = AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_DrawTextInGBK(Pointer h) { + WString str = new WString("1234567890\r\nabcdefghijklmnopqrstuvwxyz\r\n你好,欢迎使用!\r\n你號,歡迎使用!\r\n"); + + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_GBK); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInGBK(h, 0, 0, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + boolean result = AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_DrawTextInBIG5(Pointer h) { + WString str = new WString("1234567890\r\nabcdefghijklmnopqrstuvwxyz\r\n你號,歡迎使用!\r\n"); + + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_BIG5); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInBIG5(h, 0, 0, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + boolean result = AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_DrawTextInShiftJIS(Pointer h) { + WString str = new WString( + "1234567890\r\n" + + "abcdefghijklmnopqrstuvwxyz\r\n" + + "こんにちは\r\n"); + + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_ShiftJIS); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInShiftJIS(h, 0, 0, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + boolean result = AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_DrawTextInEUCKR(Pointer h) { + WString str = new WString( + "1234567890\r\n" + + "abcdefghijklmnopqrstuvwxyz\r\n" + + "왕관을 쓰려는자\r\n" + + "그 무게를 견뎌라\r\n"); + + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteMode(h); + AutoReplyPrint.INSTANCE.CP_Pos_SetMultiByteEncoding(h, AutoReplyPrint.CP_MultiByteEncoding_EUCKR); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Page_DrawTextInEUCKR(h, 0, 0, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + boolean result = AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_DrawBarcode(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 1000); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextFontType(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_BelowBarcode); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 0, AutoReplyPrint.CP_Pos_BarcodeType_UPCA, "01234567890"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 100, AutoReplyPrint.CP_Pos_BarcodeType_UPCE, "123456"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 200, AutoReplyPrint.CP_Pos_BarcodeType_EAN13, "123456789012"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 300, AutoReplyPrint.CP_Pos_BarcodeType_EAN8, "1234567"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 400, AutoReplyPrint.CP_Pos_BarcodeType_CODE39, "123456"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 500, AutoReplyPrint.CP_Pos_BarcodeType_ITF, "123456"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 600, AutoReplyPrint.CP_Pos_BarcodeType_CODEBAR, "A123456A"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 700, AutoReplyPrint.CP_Pos_BarcodeType_CODE93, "123456"); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 0, 800, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, "No.123456"); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + } + + void Test_Page_DrawBarcode_CODE128(Pointer h) { + String str = "No.123456"; + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextFontType(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_BelowBarcode); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 10, 100, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 10, 200, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, 10, 300, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextFontType(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_None); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -1, -1, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -2, -2, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -3, -3, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextFontType(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_AboveAndBelowBarcode); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -1, -1, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -2, -2, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -3, -3, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextFontType(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_AboveBarcode); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -1, -1, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -2, -2, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -3, -3, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 2); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeHeight(h, 60); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextFontType(h, 0); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeReadableTextPosition(h, AutoReplyPrint.CP_Pos_BarcodeTextPrintPosition_BelowBarcode); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -1, -1, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -2, -2, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawBarcode(h, -3, -3, AutoReplyPrint.CP_Pos_BarcodeType_CODE128, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + boolean result = AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Page_DrawQRCode(Pointer h) { + String str = "Hello"; + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 4); + AutoReplyPrint.INSTANCE.CP_Page_DrawQRCode(h, -1, -1, 0, AutoReplyPrint.CP_QRCodeECC_L, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawQRCode(h, -2, -2, 0, AutoReplyPrint.CP_QRCodeECC_L, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawQRCode(h, -3, -3, 0, AutoReplyPrint.CP_QRCodeECC_L, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 1000); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 1000, 2, 1); + AutoReplyPrint.INSTANCE.CP_Pos_SetBarcodeUnitWidth(h, 4); + AutoReplyPrint.INSTANCE.CP_Page_DrawQRCode(h, 10, 10, 10, AutoReplyPrint.CP_QRCodeECC_L, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawQRCode(h, 10, 300, 10, AutoReplyPrint.CP_QRCodeECC_L, str); + AutoReplyPrint.INSTANCE.CP_Page_DrawQRCode(h, 10, 600, 10, AutoReplyPrint.CP_QRCodeECC_L, str); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + } + + void Test_Page_DrawRasterImageFromBufferedImage(Pointer h) { + BufferedImage image = null; + try { + image = ImageIO.read(new FileInputStream("images/yellowmen.png")); + } catch (Throwable tr) { + tr.printStackTrace(); + } + if ((image == null) || (image.getWidth() == 0) || (image.getHeight() == 0)) + return; + + int srcw = image.getWidth(); + int srch = image.getHeight(); + int maxw = 384; + int maxh = 600; + int dstw = srcw; + int dsth = srch; + if (dstw > maxw) { + dstw = maxw; + dsth = maxw * srch / srcw; + } + if (dsth > maxh) { + dsth = maxh; + dstw = maxh * srcw / srch; + } + + AutoReplyPrint.INSTANCE.CP_Page_SelectPageModeEx(h, 200, 200, 0, 0, 384, 600); + AutoReplyPrint.INSTANCE.CP_Page_DrawBox(h, 0, 0, 384, 600, 2, 1); + AutoReplyPrint.CP_Page_DrawRasterImageFromData_Helper.DrawRasterImageFromBufferedImage(h, 0, 0, dstw, dsth, image, AutoReplyPrint.CP_ImageBinarizationMethod_ErrorDiffusion); + AutoReplyPrint.INSTANCE.CP_Page_PrintPage(h); + AutoReplyPrint.INSTANCE.CP_Page_ExitPageMode(h); + + Test_Pos_QueryPrintResult(h); + } + + void Test_BlackMark_EnableBlackMarkMode(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_BlackMark_EnableBlackMarkMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_BlackMark_DisableBlackMarkMode(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_BlackMark_DisableBlackMarkMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_BlackMark_SetBlackMarkMaxFindLength(Pointer h) { + int maxFindLength = 300; + + boolean result = AutoReplyPrint.INSTANCE.CP_BlackMark_SetBlackMarkMaxFindLength(h, maxFindLength); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_BlackMark_FindNextBlackMark(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_BlackMark_FindNextBlackMark(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_BlackMark_SetBlackMarkPaperPrintPosition(Pointer h) { + int position = 0; + + boolean result = AutoReplyPrint.INSTANCE.CP_BlackMark_SetBlackMarkPaperPrintPosition(h, position * 8); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_BlackMark_SetBlackMarkPaperCutPosition(Pointer h) { + int position = 0; + + boolean result = AutoReplyPrint.INSTANCE.CP_BlackMark_SetBlackMarkPaperCutPosition(h, position * 8); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_BlackMark_PrintTextOnBlackMarkPaper(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Pos_PrintText(h, "123456789012345678901234567890\r\n"); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_BlackMark_FullCutBlackMarkPaper(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_BlackMark_FullCutBlackMarkPaper(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_BlackMark_HalfCutBlackMarkPaper(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_BlackMark_HalfCutBlackMarkPaper(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_EnableLabelMode(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Label_EnableLabelMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DisableLabelMode(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Label_DisableLabelMode(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_CalibrateLabel(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Label_CalibrateLabel(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_FeedLabel(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Label_FeedLabel(h); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_SetLabelPositionAdjustment(Pointer h) { + boolean result = AutoReplyPrint.INSTANCE.CP_Printer_SetPrinterLabelPositionAdjustmentInfo(h, 0, 0); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_PageBegin_PagePrint(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawText(Pointer h) { + String str = "$$$$$$$$$$$$"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + AutoReplyPrint.INSTANCE.CP_Label_DrawText(h, 10, 10, 24, 0, str); + AutoReplyPrint.INSTANCE.CP_Label_DrawText(h, 10, 40, 24, + new AutoReplyPrint.CP_Label_TextStyle(true, true, false, false, + AutoReplyPrint.CP_Label_Rotation_0, 1, 1).getStyle(), + str); + AutoReplyPrint.INSTANCE.CP_Label_DrawText(h, 10, 70, 24, + new AutoReplyPrint.CP_Label_TextStyle(false, false, false, false, + AutoReplyPrint.CP_Label_Rotation_0, 2, 2).getStyle(), + str); + AutoReplyPrint.INSTANCE.CP_Label_DrawText(h, 30, 130, 24, + new AutoReplyPrint.CP_Label_TextStyle(false, false, false, false, + AutoReplyPrint.CP_Label_Rotation_90, 1, 1).getStyle(), + str); + AutoReplyPrint.INSTANCE.CP_Label_DrawText(h, 40, 200, 26, 0, str); + AutoReplyPrint.INSTANCE.CP_Label_DrawText(h, 40, 240, 28, 0, str); + AutoReplyPrint.INSTANCE.CP_Label_DrawText(h, 40, 280, 16, 0, str); + AutoReplyPrint.INSTANCE.CP_Label_DrawText(h, 40, 320, 21, 0, str); + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_UPCA(Pointer h) { + String str = "01234567890"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_UPCA, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, (byte) 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_UPCE(Pointer h) { + String str = "123456"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_UPCE, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, (byte) 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_EAN13(Pointer h) { + String str = "123456789012"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_EAN13, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, (byte) 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_EAN8(Pointer h) { + String str = "1234567"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_EAN8, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_CODE39(Pointer h) { + String str = "123456"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_CODE39, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_ITF(Pointer h) { + String str = "123456"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_ITF, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_CODEBAR(Pointer h) { + String str = "A123456A"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_CODEBAR, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_CODE93(Pointer h) { + String str = "123456"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_CODE93, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBarcode_CODE128(Pointer h) { + String str = "No.123456"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawBarcode(h, 10, 10, AutoReplyPrint.CP_Label_BarcodeType_CODE128, AutoReplyPrint.CP_Label_BarcodeTextPrintPosition_BelowBarcode, 60, 2, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawQRCode(Pointer h) { + String str = "Hello 你好"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawQRCode(h, 10, 10, 0, AutoReplyPrint.CP_QRCodeECC_L, 8, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawPDF417Code(Pointer h) { + String str = "Hello 你好"; + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + + AutoReplyPrint.INSTANCE.CP_Label_DrawPDF417Code(h, 10, 10, 3, 3, 0, 3, AutoReplyPrint.CP_Label_Rotation_0, str); + + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawLine(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + AutoReplyPrint.INSTANCE.CP_Label_DrawLine(h, 20, 20, 100, 300, 1, AutoReplyPrint.CP_Label_Color_Black); + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawRect(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + AutoReplyPrint.INSTANCE.CP_Label_DrawRect(h, 20, 20, 200, 10, AutoReplyPrint.CP_Label_Color_Black); + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawBox(Pointer h) { + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, 384, 400, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, 384, 400, 1, AutoReplyPrint.CP_Label_Color_Black); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 30, 30, 300, 200, 1, AutoReplyPrint.CP_Label_Color_Black); + boolean result = AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + if (!result) + TestUtils.showMessageOnUiThread("Write failed"); + } + + void Test_Label_DrawImageFromBufferedImage(Pointer h) { + BufferedImage image = null; + try { + image = ImageIO.read(new FileInputStream("images/yellowmen.png")); + } catch (Throwable tr) { + tr.printStackTrace(); + } + if ((image == null) || (image.getWidth() == 0) || (image.getHeight() == 0)) + return; + + int printwidth = 384; + int dstw = printwidth; + int dsth = (int) (dstw * ((double) image.getHeight() / image.getWidth())); + + AutoReplyPrint.INSTANCE.CP_Label_PageBegin(h, 0, 0, dstw, dsth, AutoReplyPrint.CP_Label_Rotation_0); + AutoReplyPrint.INSTANCE.CP_Label_DrawBox(h, 0, 0, dstw, dsth, 1, AutoReplyPrint.CP_Label_Color_Black); + AutoReplyPrint.CP_Label_DrawImageFromData_Helper.DrawImageFromBufferedImage(h, 0, 0, dstw, dsth, image, AutoReplyPrint.CP_ImageBinarizationMethod_ErrorDiffusion, AutoReplyPrint.CP_ImageCompressionMethod_None); + AutoReplyPrint.INSTANCE.CP_Label_PagePrint(h, 1); + Test_Pos_QueryPrintResult(h); + } + +} diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/utils/TestUtils.java b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/TestUtils.java new file mode 100644 index 0000000..20ffbd4 --- /dev/null +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/utils/TestUtils.java @@ -0,0 +1,30 @@ +package com.dpkj.modules.autoReplyPrint.utils; + +import javax.swing.*; +import java.io.FileInputStream; +import java.io.InputStream; + +public class TestUtils { + public static byte[] ReadFromFile(String fileName) { + byte[] data = null; + try { + InputStream in = new FileInputStream(fileName); + data = new byte[in.available()]; + in.read(data); + in.close(); + } catch (Throwable tr) { + tr.printStackTrace(); + } + + return data; + } + + public static void showMessageOnUiThread(final String msg) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + JOptionPane.showMessageDialog(null, msg); + } + }); + } +} diff --git a/src/main/java/com/dpkj/modules/cardReader/utils/CardReaderUtil.java b/src/main/java/com/dpkj/modules/cardReader/utils/CardReaderUtil.java index 81e1e77..f101be4 100644 --- a/src/main/java/com/dpkj/modules/cardReader/utils/CardReaderUtil.java +++ b/src/main/java/com/dpkj/modules/cardReader/utils/CardReaderUtil.java @@ -16,8 +16,10 @@ public class CardReaderUtil { public static CardReaderSdk getCardReaderSDK() throws CardReaderRegistrationException { try { return Native.load("UnPack", CardReaderSdk.class); + //return Native.load("SSSE32", CardReaderSdk.class); + //return Native.load("autoreplyprint", CardReaderSdk.class); } catch (UnsatisfiedLinkError e) { - log.info("[CardReader][CardReaderUtil.getCardReaderSDK] SDK注册失败 {}", e.getMessage()); + log.info("[CardReader][AutoReplyPrint2.getCardReaderSDK] SDK注册失败 {}", e.getMessage()); throw new CardReaderRegistrationException("Failed to load CardReaderSdk library: ", e); } } diff --git a/src/main/java/com/dpkj/modules/receiptsPrint/service/impl/ReceiptsPrintServiceImpl.java b/src/main/java/com/dpkj/modules/receiptsPrint/service/impl/ReceiptsPrintServiceImpl.java index bb0e389..0635ed9 100644 --- a/src/main/java/com/dpkj/modules/receiptsPrint/service/impl/ReceiptsPrintServiceImpl.java +++ b/src/main/java/com/dpkj/modules/receiptsPrint/service/impl/ReceiptsPrintServiceImpl.java @@ -1,6 +1,5 @@ package com.dpkj.modules.receiptsPrint.service.impl; -import com.caysn.autoreplyprint.AutoReplyPrint; import com.dpkj.modules.receiptsPrint.service.ReceiptsPrintService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -16,7 +15,7 @@ public class ReceiptsPrintServiceImpl implements ReceiptsPrintService { @Override public void test() { - System.out.println(AutoReplyPrint.CP_CharacterSet_CHINA); + //System.out.println(AutoReplyPrint.CP_CharacterSet_CHINA); } } diff --git a/src/main/resources/autoreplyprint/linux-x64/.gitignore b/src/main/resources/autoreplyprint/linux-x64/.gitignore new file mode 100644 index 0000000..a093304 --- /dev/null +++ b/src/main/resources/autoreplyprint/linux-x64/.gitignore @@ -0,0 +1,3 @@ +autoreplyprint.h +libautoreplyprint.so* + diff --git a/src/main/resources/autoreplyprint/linux-x64/dependencies.txt b/src/main/resources/autoreplyprint/linux-x64/dependencies.txt new file mode 100644 index 0000000..1d2cbd0 --- /dev/null +++ b/src/main/resources/autoreplyprint/linux-x64/dependencies.txt @@ -0,0 +1,2 @@ +ldd libautoreplyprint.so + diff --git a/src/main/resources/autoreplyprint/linux-x64/update.sh b/src/main/resources/autoreplyprint/linux-x64/update.sh new file mode 100644 index 0000000..91b430e --- /dev/null +++ b/src/main/resources/autoreplyprint/linux-x64/update.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cp ../../../autoreplyprint_src/autoreplyprint_main/autoreplyprint.h . +cp ../../build-autoreplyprint-Qt_5_6_3_x64_static-Release/libautoreplyprint.so* . + diff --git a/src/main/resources/autoreplyprint/linux-x86/.gitignore b/src/main/resources/autoreplyprint/linux-x86/.gitignore new file mode 100644 index 0000000..a093304 --- /dev/null +++ b/src/main/resources/autoreplyprint/linux-x86/.gitignore @@ -0,0 +1,3 @@ +autoreplyprint.h +libautoreplyprint.so* + diff --git a/src/main/resources/autoreplyprint/linux-x86/dependencies.txt b/src/main/resources/autoreplyprint/linux-x86/dependencies.txt new file mode 100644 index 0000000..1d2cbd0 --- /dev/null +++ b/src/main/resources/autoreplyprint/linux-x86/dependencies.txt @@ -0,0 +1,2 @@ +ldd libautoreplyprint.so + diff --git a/src/main/resources/autoreplyprint/linux-x86/update.sh b/src/main/resources/autoreplyprint/linux-x86/update.sh new file mode 100644 index 0000000..5321ae7 --- /dev/null +++ b/src/main/resources/autoreplyprint/linux-x86/update.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cp ../../../autoreplyprint_src/autoreplyprint_main/autoreplyprint.h . +cp ../../build-autoreplyprint-Qt_5_6_3_x86_static-Release/libautoreplyprint.so* . + diff --git a/src/main/resources/autoreplyprint/mac/.gitignore b/src/main/resources/autoreplyprint/mac/.gitignore new file mode 100644 index 0000000..92f6b40 --- /dev/null +++ b/src/main/resources/autoreplyprint/mac/.gitignore @@ -0,0 +1,3 @@ +autoreplyprint.h +libautoreplyprint*.dylib + diff --git a/src/main/resources/autoreplyprint/mac/dependencies.txt b/src/main/resources/autoreplyprint/mac/dependencies.txt new file mode 100644 index 0000000..1d2cbd0 --- /dev/null +++ b/src/main/resources/autoreplyprint/mac/dependencies.txt @@ -0,0 +1,2 @@ +ldd libautoreplyprint.so + diff --git a/src/main/resources/autoreplyprint/mac/update.sh b/src/main/resources/autoreplyprint/mac/update.sh new file mode 100644 index 0000000..e3c354b --- /dev/null +++ b/src/main/resources/autoreplyprint/mac/update.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cp ../../../autoreplyprint_src/autoreplyprint_main/autoreplyprint.h . +cp ../../build-autoreplyprint-Desktop_Qt_5_12_0_clang_64bit-Release/libautoreplyprint*.dylib . + diff --git a/src/main/resources/autoreplyprint/win32/.gitignore b/src/main/resources/autoreplyprint/win32/.gitignore new file mode 100644 index 0000000..f030e1c --- /dev/null +++ b/src/main/resources/autoreplyprint/win32/.gitignore @@ -0,0 +1,4 @@ +autoreplyprint.dll +autoreplyprint.exp +autoreplyprint.lib +autoreplyprint.h diff --git a/src/main/resources/autoreplyprint/win32/copydll.bat b/src/main/resources/autoreplyprint/win32/copydll.bat new file mode 100644 index 0000000..c58d561 --- /dev/null +++ b/src/main/resources/autoreplyprint/win32/copydll.bat @@ -0,0 +1,4 @@ +copy ..\..\build-autoreplyprint-QT5_6_3_VC2015_STATIC_32-Release\release\autoreplyprint.dll . /y +copy ..\..\build-autoreplyprint-QT5_6_3_VC2015_STATIC_32-Release\release\autoreplyprint.exp . /y +copy ..\..\build-autoreplyprint-QT5_6_3_VC2015_STATIC_32-Release\release\autoreplyprint.lib . /y +copy ..\..\..\autoreplyprint_src\autoreplyprint_main\autoreplyprint.h . /y diff --git a/src/main/resources/autoreplyprint/win64/.gitignore b/src/main/resources/autoreplyprint/win64/.gitignore new file mode 100644 index 0000000..f030e1c --- /dev/null +++ b/src/main/resources/autoreplyprint/win64/.gitignore @@ -0,0 +1,4 @@ +autoreplyprint.dll +autoreplyprint.exp +autoreplyprint.lib +autoreplyprint.h diff --git a/src/main/resources/autoreplyprint/win64/copydll.bat b/src/main/resources/autoreplyprint/win64/copydll.bat new file mode 100644 index 0000000..50e0ea7 --- /dev/null +++ b/src/main/resources/autoreplyprint/win64/copydll.bat @@ -0,0 +1,4 @@ +copy ..\..\build-autoreplyprint-QT5_6_0_VC2015_STATIC_64-Release\release\autoreplyprint.dll . /y +copy ..\..\build-autoreplyprint-QT5_6_0_VC2015_STATIC_64-Release\release\autoreplyprint.exp . /y +copy ..\..\build-autoreplyprint-QT5_6_0_VC2015_STATIC_64-Release\release\autoreplyprint.lib . /y +copy ..\..\..\autoreplyprint_src\autoreplyprint_main\autoreplyprint.h . /y diff --git a/src/main/resources/autoreplyprint/目录说明.txt b/src/main/resources/autoreplyprint/目录说明.txt new file mode 100644 index 0000000..1aa3caa --- /dev/null +++ b/src/main/resources/autoreplyprint/目录说明.txt @@ -0,0 +1,10 @@ +考虑到应用场景 +1 WIN10系统编译32位,64位动态库。 + 可能要到XP系统下面去使用,开发例子程序。 + 比如VS2005 C++ C# + 也可能去其他系统下面使用,开发例子程序。 +2 可能要生成多种系统下的库,一起放到某个位置 + +考虑到以上应用场景 +1 决定每个目录单独一个文件夹,同时包括头文件和库文件。 +2 使用的时候,直接目录复制过去即可使用。 diff --git a/src/main/resources/win32-x86-64/SSSE32.H b/src/main/resources/win32-x86-64/SSSE32.H new file mode 100644 index 0000000..5808cab --- /dev/null +++ b/src/main/resources/win32-x86-64/SSSE32.H @@ -0,0 +1,350 @@ +#ifndef SSSE32_H +#define SSSE32_H +#include +#include + +//״̬�� +#define IFD_OK 0 //ִ�гɹ� +#define IFD_ICC_TypeError -1 //��Ƭ���Ͳ��� +#define IFD_ICC_NoExist -2 //�޿� +#define IFD_ICC_NoPower -3 //�п�δ�ϵ� +#define IFD_ICC_NoResponse -4 //��Ƭ��Ӧ�� +#define IFD_ConnectError -11 //���������Ӵ� +#define IFD_UnConnected -12 //δ��������(û��ִ�д��豸����) +#define IFD_BadCommand -13 //(��̬��)��֧�ָ����� +#define IFD_ParameterError -14 //(������̬���)��������� +#define IFD_CheckSumError -15 //��ϢУ��ͳ��� +#define IFD_OutTime -20 //��ϢУ��ͳ��� +#define IFD_False -21 //����ִ��ʧ�� + + +#ifdef __cplusplus +extern "C" { +#endif +// +/*############�豸��������#################*/ +long WINAPI ICC_Reader_Open(char* dev_Name); +long WINAPI ICC_Reader_Close(long ReaderHandle); +long WINAPI ICC_PosBeep(long ReaderHandle, unsigned char time);//���� +long WINAPI ICC_Reader_EnterDFU (long ReaderHandle); //����USB���س���״̬ +long WINAPI ICC_Reader_LeaveDFU (long ReaderHandle); //�뿪USB���س���״̬ +long WINAPI ICC_Reader_Libinfo(char* info); +long WINAPI ICC_Reader_ReadEEPROM (long ReaderHandle,int offset,int length,unsigned char *buffer);//��eeprom��ȡ���� +long WINAPI ICC_Reader_WriteEEPROM (long ReaderHandle,int offset,int length,unsigned char *buffer);//��eepromд������ +long WINAPI ICC_Machine_Reset(long ReaderHandle); +void WINAPI ICC_Reader_PPS(bool IsEnable); +long WINAPI ICC_Reader_GetDeviceVersion(long ReaderHandle, unsigned char *VDate); +long WINAPI ICC_Reader_GetKeybordVersion(long ReaderHandle,char *VDate); + +long WINAPI ICC_Reader_GetDeviceSN(long ReaderHandle,char* dev_Ser); //��ȡ�豸���кţ����豸��ȡ +long WINAPI ICC_Reader_SetDeviceSN(long ReaderHandle,char* dev_Ser); //�����豸���к� + +long WINAPI ICC_Reader_ContatctInfo(long ReaderHandle,char *VDate); //��ȡ�Ӵ����ܱ� +long WINAPI ICC_Reader_NoContatctInfo(long ReaderHandle,char *VDate);//��ȡ�ǽӹ��ܱ� +long WINAPI ICC_Reader_GetDeviceCSN(long ReaderHandle,unsigned char *data); +long WINAPI ICC_DispInfo(long ReaderHandle,unsigned char row,unsigned char list,char *data); //��ʾ��Ϣ +long WINAPI ICC_DispSound(long ReaderHandle,unsigned char type,unsigned char nMode); //������ʾ��Ϣ type(1~14) nMode==0���ü���������nMode==1���ü������� +/* + 1����忨 2����ˢ�� 3���������� 4������������ 5��������� 6�������ɹ� 7��������ʱ 8������ʧ�� 9����ȡ�ؿ� 10���������������� 11�����ٴ��������� 12�������������� 13������������� 14����ȷ�������� +*/ + +long WINAPI ICC_CtlLight(long ReaderHandle);//���������� +long WINAPI ICC_ChangeLight(long ReaderHandle,unsigned char mode);//�ı���Ļ���� mode=1 ���� mode=0���� +long WINAPI ICC_GetInputPass(long ReaderHandle, unsigned char ctime, unsigned char *rlen, unsigned char start,unsigned char stop,unsigned char * cpass);//��ȡ���룬����ʱ start==0�����ü��̣�start==1�����ü��� +long WINAPI ICC_GetInputPassID(long ReaderHandle, unsigned char ctime, unsigned char *rlen, unsigned char start,unsigned char stop,unsigned char * cardID,unsigned char * cpass);//��ȡ���룬����ʱ,��ID +long WINAPI ICC_GetTimeOut(long ReaderHandle,unsigned char flag);//��ȡ���롢��������ʱ +long WINAPI ICC_PassGet(long ReaderHandle,unsigned char *rlen,unsigned char time,unsigned char start,unsigned char stop,unsigned char * cpass);//��ȡ���� +long WINAPI ICC_PassGetID(long ReaderHandle,unsigned char *rlen,unsigned char time,unsigned char start,unsigned char stop,unsigned char * cardID,unsigned char * cpass);//��ȡ���룬������ +long WINAPI ICC_PassCheck(long ReaderHandle,unsigned char *rlen,unsigned char * cpass); //���������Ƿ��� +long WINAPI ICC_PassSetDES(long ReaderHandle,unsigned char DES); //���ü���ģʽ3des or des +long WINAPI ICC_PassSetDevID(long ReaderHandle,unsigned char *devID);//���ü����豸ID +long WINAPI ICC_PassGetDevID(long ReaderHandle,unsigned char *devID);//��ȡ�����豸ID +long WINAPI ICC_PassSetKeyLen(long ReaderHandle,unsigned char len);//�������볤�� +long WINAPI ICC_Reader_Auto(long ReaderHandle,int t_IntType); +long WINAPI PICC_Reader_ID_N(long ReaderHandle,unsigned char *GetData); +/*###############################################*/ + +long WINAPI ICC_PassGetSG(long ReaderHandle,unsigned char *rlen,unsigned char * cpass); +long WINAPI ICC_GetInputPassSG(long ReaderHandle, unsigned char *rlen,unsigned char * cpass); + +/*############�Ӵ�CPU��������#################*/ +long WINAPI ICC_Reader_pre_PowerOn(long ReaderHandle,unsigned char ICC_Slot_No,unsigned char* Response);//�ϵ� �� �������ݳ��� +long WINAPI ICC_Reader_hot_PowerOn(long ReaderHandle,unsigned char ICC_Slot_No,unsigned char* Response);//�ϵ� �� �������ݳ��� + +long WINAPI ICC_Reader_Zpre_PowerOn(long ReaderHandle,unsigned char ICC_Slot_No,unsigned char* Response);//ס����С�� +long WINAPI ICC_Reader_PowerOn(long ReaderHandle,unsigned char ICC_Slot_No,unsigned char* Response);//�ϵ� �������ݳ��� ��+�� +long WINAPI ICC_Reader_PowerOnHEX(long ReaderHandle,unsigned char ICC_Slot_No,unsigned char* Response);//�ϵ� ��+�� �������ݳ��� +/* + ����ICC_Slot_No��0x01 + SAM1:0x11 + SAM2:0x12 + SAM3:0x13 + SAM4:0x14 + ��ͬ + +*/ +long WINAPI ICC_Reader_PowerOff(long ReaderHandle,unsigned char ICC_Slot_No);//�µ� + +long WINAPI ICC_Reader_GetStatus(long ReaderHandle,unsigned char ICC_Slot_No);//��ȡ����״̬ + +long WINAPI ICC_Reader_Application(long ReaderHandle,unsigned char ICC_Slot_No, + long Lenth_of_Command_APDU,unsigned char* Command_APDU, + unsigned char* Response_APDU); //ִ��apdu���� �������ݳ��� + +long WINAPI ICC_Reader_LongApplication(long ReaderHandle,unsigned char ICC_Slot_No, + long Lenth_of_Command_APDU,unsigned char* Command_APDU, + unsigned char* Response_APDU); //ִ��apdu���� �������ݳ��� + +//cpuetu=01��02��03��04����IJ����ʷֱ�Ϊ9600��19200��38400��115200 +//unsigned char cpupro ---- ����Э������ =0��ʾT=0Э�� =1��ʾT=1Э�� +long WINAPI ICC_SetCpupara(long ReaderHandle,unsigned char ICC_Slot_No,unsigned char cpupro,unsigned char cpuetu);//�������� +long WINAPI ICC_SetCpuETU(long ReaderHandle,unsigned char ICC_Slot_No,unsigned char cpupro,unsigned char cpuetu);//�������� + + +long WINAPI PICC_Reader_SetTypeA(long ReaderHandle);//���ö�typeA +long WINAPI PICC_Reader_SetTypeB(long ReaderHandle);//���ö�typeB +long WINAPI PICC_Reader_Select(long ReaderHandle,unsigned char cardtype);//ѡ��Ƭ��41Ϊtypea,M1 42Ϊtypeb,TypeB��Ƭ�����ϵ��ѡ�� +long WINAPI PICC_Reader_Request(long ReaderHandle);//typea M1����Ƭ +long WINAPI PICC_Reader_RFControl(long ReaderHandle,short flag);//flag=0 �ر����� flag=1 ������ +long WINAPI PICC_Reader_anticoll(long ReaderHandle,unsigned char *uid);//����ײ typea M1��Ƭ + +/*############ M1����������#################*/ +long WINAPI PICC_Reader_M1Rest(long ReaderHandle,unsigned char *uid); +long WINAPI PICC_Reader_Authentication(long ReaderHandle,unsigned char Mode, unsigned char SecNr);//��֤��Կ M1 +long WINAPI PICC_Reader_Authentication_Pass(long ReaderHandle,unsigned char Mode, unsigned char SecNr,unsigned char *PassWord);//��֤��ԿM1 ����Կ���� +long WINAPI PICC_Reader_Readval(long ReaderHandle,unsigned char Addr,unsigned long *value); //��ֵ +long WINAPI PICC_Reader_Initval(long ReaderHandle,unsigned char Addr,unsigned long value);//��ʼ��ֵ +long WINAPI PICC_Reader_Increment(long ReaderHandle,unsigned char Addr,unsigned long value); //��ֵ +long WINAPI PICC_Reader_Decrement(long ReaderHandle,unsigned char Addr,unsigned long value);//��ֵ +long WINAPI PICC_Reader_Read(long ReaderHandle,unsigned char Addr,unsigned char *Data); //��ȡ��ƬM1 +long WINAPI PICC_Reader_Write(long ReaderHandle,unsigned char Addr,unsigned char *Data);//д������M1 +long WINAPI PICC_Reader_LoadKey(long ReaderHandle,unsigned char Mode,unsigned char SecNr,unsigned char *Key);//װ����Կ +long WINAPI PICC_Reader_ReadHEX(long ReaderHandle,unsigned char Addr,unsigned char *DataHex); //��ȡ��ƬM1 + +long WINAPI PICC_Reader_WriteHEX(long ReaderHandle,unsigned char Addr,unsigned char *DataHex);//д������M1 +/* +SecNr:������ +Mode��01 02 03 �ֱ�Ϊ��һ������������ԿKeyA +04 05 06 �ֱ�Ϊ��һ������������ԿKEYB +*/ +/*############ ID ���� #####################################*/ +long WINAPI PICC_Reader_IdCard(long ReaderHandle,unsigned char *Number); + +/*############ TypeA CPU ���������� #################*/ +long WINAPI PICC_Reader_PowerOnTypeA(long ReaderHandle,unsigned char* Response);//�ϵ� �������ݳ��� ʧ��С��0 + +/*############ TypeB CPU ����������#################*/ +long WINAPI PICC_Reader_PowerOnTypeB(long ReaderHandle,unsigned char* Response);//�ϵ� �������ݳ��� ʧ��С��0 +long WINAPI ICC_Reader_ApplicationHEX(long ReaderHandle,unsigned char ICC_Slot_No, + char* Command_APDU, + char* Response_APDU); //ִ��apdu���� �������ݳ��� + + +long WINAPI PICC_Reader_Application(long ReaderHandle, + long Lenth_of_Command_APDU,unsigned char* Command_APDU, + unsigned char* Response_APDU); //type a/bִ��apdu���� �������ݳ��� ʧ��С��0 + +long WINAPI HD_USBkey(long ReaderHandle,unsigned char _Adr, int len);//ģ����� + +//############################### ���� Flash ########################################################## +long WINAPI ICC_Reader_ReadFlash(long ReaderHandle,int offset,int len,unsigned char *data); +long WINAPI ICC_Reader_WriteFlash(long ReaderHandle,int offset,int len,unsigned char *data); + +//############################### �����֤ ############################################################ + +long WINAPI PICC_Read_SAM(long ReaderHandle,unsigned char* strSam); +long WINAPI Base64_encode(char *bytes_to_encode, int in_len,int *out_len,char * t_outpData);//Base64���� + +long WINAPI iReadCertInfo(long m_hReader,int iType, char *pPhotoPath, char *pPhotoData, char *Info); +long WINAPI PICC_Reader_ID_Request(long ReaderHandle);//���֤Ѱ�� +long WINAPI PICC_Reader_ID_Select(long ReaderHandle);//���֤ѡ�� +long WINAPI PICC_Reader_ID_Read(long ReaderHandle,unsigned char* Response);//���֤���� +long WINAPI PICC_Reader_ID_Read2(long ReaderHandle,unsigned char *data);/*��ȡ���֤ ��Ӷ�ȡָ����Ϣ*/ +long WINAPI PICC_Reader_Read_CardID(long ReaderHandle,unsigned char* Response);//�����֤ID +long WINAPI PICC_Reader_ReadIDMsgWG(long ReaderHandle, const char* pBmpFile, char *pName, char *pSex, char *pNation, char *pBirth, char *pAddress, char *pCertNo, char *pDepartment , char *pEffectData, char *pExpire,char * pErrMsg,char * cardtype); +long WINAPI PICC_Reader_ReadIDMsg(long ReaderHandle, const char* pBmpFile, char *pName, char *pSex, char *pNation, char *pBirth, char *pAddress, char *pCertNo, char *pDepartment , char *pEffectData, char *pExpire,char * pErrMsg); +long WINAPI PICC_Reader_ReadIDInfo(long ReaderHandle, const char* pBmpFile, char *pName, char *pSex, char *pNation, char *pBirth, char *pAddress, char *pCertNo, char *pDepartment , char *pEffectData, char *pExpire,char * pErrMsg); +long WINAPI PICC_Reader_ReadIDMsg2(long ReaderHandle, char *pName, char *pSex, char *pNation, char *pBirth, char *pAddress, char *pCertNo, char *pDepartment , char *pEffectData, char *pExpire,unsigned char * tupian,char * pErrMsg);//ͼƬ��Ϣ�洢��tupian���� +long WINAPI PICC_Reader_ReadIDInfo2(long ReaderHandle,const char* pBmpFile,char *pName, char *pSex, char *pNation, char *pBirth, char *pAddress, char *pCertNo, char *pDepartment , char *pEffectData, char *pExpire,char *pFing,char * pErrMsg,char *pCardDex,char *pOrganID,char *txzhm , char * qfcs); +long WINAPI PICC_Reader_ID_CertInfo (long ReaderHandle, const char*pBmpFile, char *pName, char *pSex, char *pNation, char *pBirth, char*pAddress, char *pCertNo, char *pDepartment , char *pEffectData, char*pExpire, char *pPassPortNO, char *pSignTimes, char *pIDType, char*PhotoInBase64 ); +//��Ӷ�ȡָ����Ϣ ���pBmpFile==NULL����������Ƭ������������Ƭ�������봫��·�������磺C:/zhaopian/zp.bmp +long WINAPI PICC_Reader_ReadIDPhotoInfo(long ReaderHandle, char* pBmpFileData, char *pName, char *pSex, char *pNation, char *pBirth, char *pAddress, char *pCertNo, char *pDepartment , char *pEffectData, char *pExpire,char * pErrMsg); + +//################################����������################################################################ +long WINAPI Rcard(long ReaderHandle,unsigned char ctime,int track,unsigned char *rlen,unsigned char *getdata);//�������� +long WINAPI ICC_Reader_GetMagCardMode(long ReaderHandle,unsigned char *GetData); //��ȡ�������ģʽ +long WINAPI ICC_Reader_SetMagCardMode(long ReaderHandle,int mode, unsigned char* InData); //���ô������ģʽ +long WINAPI PICC_Reader_SetMsg(long ReaderHandle ,unsigned char t_flag, unsigned char *SendData,int t_len, unsigned char *GetData); + + +//////////////////////////////////////////////////////////////////////////2G 20170411 +long WINAPI PICC_Reader_2G_IPCtrl(long ReaderHandle,unsigned char type,unsigned char cIPlen,unsigned char *ipData,unsigned char cPortlen,unsigned char *portData);//����IP +long WINAPI PICC_Reader_2G_TimeCON(long ReaderHandle,unsigned char TimeConfig);//����ʱ�� +long WINAPI PICC_Reader_2G_IPState(long ReaderHandle,unsigned char typeState);//����ʱ�� + +long WINAPI ICC_GetInputPassEx(long ReaderHandle, unsigned char ctime, int *rlen, unsigned char * cpass, int disinfo,unsigned char type);//xians yuyin + +//////////////////////////////////////////////////////////////////////////20170712 + +long WINAPI PICC_Reader_OpenClose(long ReaderHandle,unsigned char typeState) ;//�������� + +/*######################ɨ�����λ############*/ +long WINAPI ICC_CtrScanCode(long ReaderHandle,int InFlag, int WFlag) ; +long WINAPI ICC_ScanCodeSM(long ReaderHandle, int time ,unsigned char*pCodeInfo,int WFlag); + + + +long WINAPI ICC_ScanCodeStar(long ReaderHandle, unsigned char*pCodeInfo,int WFlag); + +long WINAPI ICC_ScanCodeStop(long ReaderHandle ,unsigned char*pCodeInfo,int WFlag); + +long WINAPI ICC_ScanCodeRead(long ReaderHandle, unsigned char*pCodeInfo); + +long WINAPI StrToHex(unsigned char *Src, int len,unsigned char *Des); +long WINAPI HexToStr(unsigned char *Src,int len,unsigned char *Des ); +/*#####################��Ļ��ʾ#####################*/ + +long WINAPI ICC_Reader_DownloadPhoto(long ReaderHandle,int Pnumber, char* Addr); +long WINAPI ICC_Reader_DownloadParamControl(long ReaderHandle,int FlagNO, long TimeData ); +long WINAPI ICC_Reader_ShowQRCode(long ReaderHandle,long momey, int lent,unsigned char * Addr ); +long WINAPI ICC_Reader_CloseQRCode(long ReaderHandle ); + +long WINAPI ICC_GetBankCardNo(long ReaderHandle,int nType,unsigned char* bankCardNo,int* bankCardNoLen) ;//���п����� nType = 0x00 ѡ��Ӵ�����0x01ѡ��ǽӿ� ����0λִ�гɹ�����0ʧ�� +long WINAPI PICC_Reader_SSCardInfo1(long ReaderHandle,unsigned char* pSSCardID ,unsigned char* pIDNum , unsigned char* pName ,unsigned char* pSex ,unsigned char* pBorn ) ; + +long WINAPI PICC_Reader_SSCard(long ReaderHandle,unsigned char* pSSCardID ); + +long WINAPI ReadMifare(long ReaderHandle,int block,unsigned char * password, unsigned char* ReData); + +long WINAPI WriteMifare(long ReaderHandle,int block,unsigned char * password, unsigned char* ReData); + +long WINAPI PICC_Reader_GATIDMsg(long ReaderHandle, const char* pBmpFile, char *pName, char *pSex , char *pBirth, char *pAddress, char *pCertNo, char *pDepartment , char *pEffectData, char *pExpire,char * txIDNO , char * number,char* zhengjialx,char * pErrMsg); +/*###############################��������#######################*/ + + +int WINAPI IC_Init(int Port); //���豸���� +int WINAPI IC_Exit(); //�ر��豸���� +int WINAPI IC_CardRead(const char *file_name, char *data); //��ȡ��Ƭ�ļ� ������� file_name ��Ҫ��ȡ�ļ����� ����0001 +int WINAPI IC_CardNo(char *data); //��ȡ��Ƭ���к� +int WINAPI IC_CardInfo(char *data); //��ȡ�û�����Ƭ��Ϣ +int WINAPI IC_CardRandom(char *data); //��ȡ��Ƭ����� +int WINAPI IC_CardWrite(const char *info); //д�� info�����뱨����Ϣ��ע�����Ҫ��14�����ݣ�Ҳ������14����|���ָ���磺1|2|3|4|5|6|7|8|9|10|11|12|13|14|�� +int WINAPI ICC_GetStatus(int so); +/*##################4428*/ +/*############ 4428 ������������#################*/ + +long WINAPI ICC_Reader_4428_PowerOn(long ReaderHandle,unsigned char *data); //4428���ϵ� +long WINAPI ICC_Reader_4428_PowerOnHEX(long ReaderHandle,unsigned char *dataHex); //4428���ϵ磬����HEX�� +long WINAPI ICC_Reader_4428_PowerOff(long ReaderHandle); //4428���µ� +long WINAPI ICC_Reader_4428_Read(long ReaderHandle,int offset,int len,unsigned char *data); //4428�������� +long WINAPI ICC_Reader_4428_ReadHEX(long ReaderHandle,int offset,int len,unsigned char *dataHex); //4428�������ݣ�����HEX�� +long WINAPI ICC_Reader_4428_Write(long ReaderHandle,int offset,int len,unsigned char *data); //4428��д���� +long WINAPI ICC_Reader_4428_WriteHEX(long ReaderHandle,int offset,int len,unsigned char *dataHEX); //4428��д���ݣ�����HEX�� +long WINAPI ICC_Reader_4428_Verify(long ReaderHandle,unsigned char *key); //4428����֤��Կ +long WINAPI ICC_Reader_4428_VerifyHEX(long ReaderHandle,unsigned char *keyHex); //4428����֤��Կ��������ԿΪHEX�� +long WINAPI ICC_Reader_4428_Change(long ReaderHandle,unsigned char *newkey); //4428���޸���Կ +long WINAPI ICC_Reader_4428_ChangeHEX(long ReaderHandle,unsigned char *newkeyHex); //4428���޸���Կ��������ԿΪHEX�� +long WINAPI ICC_Reader_4428_ReadProtect(long ReaderHandle,int offset,int len,unsigned char *data); //4428������������ +long WINAPI ICC_Reader_4428_WriteProtect(long ReaderHandle,int offset,int len,unsigned char *data); //4428��д�������� +long WINAPI ICC_Reader_4428_ReadCount(long ReaderHandle); //��ȡ4428����Կʣ����֤���� ���ش���0~8�� + + + +/*############ 4442������������#################*/ +long WINAPI ICC_Reader_ChangeSlot(long ReaderHandle,unsigned char icc_slot_no);/*�л���2��2������*/ +long WINAPI ICC_Reader_4442_PowerOn(long ReaderHandle,unsigned char *data); //4442���ϵ� �������ݳ��� +long WINAPI ICC_Reader_4442_PowerOff(long ReaderHandle); //4442���µ� +long WINAPI ICC_Reader_4442_Read(long ReaderHandle,int offset,int len,unsigned char *data); //4442�������� +long WINAPI ICC_Reader_4442_Write(long ReaderHandle,int offset,int len,unsigned char *data); //4442��д���� +long WINAPI ICC_Reader_4442_Verify(long ReaderHandle,unsigned char *key); //4442����֤��Կ +long WINAPI ICC_Reader_4442_Change(long ReaderHandle,unsigned char *newkey); //4442���޸���Կ +long WINAPI ICC_Reader_4442_ReadProtect(long ReaderHandle,int offset,int len,unsigned char *data); //4442������������ +long WINAPI ICC_Reader_4442_WriteProtect(long ReaderHandle,int offset,int len,unsigned char *data); //4442��д�������� +long WINAPI ICC_Reader_4442_ReadCount(long ReaderHandle); //��ȡ4442����Կʣ����֤���� ���ش���0~3�� + + +long WINAPI ICC_Reader_4442_ReadData(long ReaderHandle,int offset,int len,unsigned char *data); + +long WINAPI ICC_Reader_4442_WriteData(long ReaderHandle,unsigned char *key,int offset,int len,unsigned char *data); + + + + + +/*############ 15693 ����������#################*/ + +long WINAPI PICC_Reader_Inventory(long ReaderHandle,unsigned char* Response_APDU);//������ͨ������ͻ���ڵõ��������������п�Ƭ�����к� +long WINAPI PICC_Reader_15693_Read(long ReaderHandle,unsigned char blk_add,unsigned char* Response_APDU);//������ȡ1��������ֵ +long WINAPI PICC_Reader_15693_Write(long ReaderHandle,unsigned char blk_add,unsigned char* data, + unsigned char* Response_APDU);//��һ�������д������ÿ��ֻ��дһ���飩 +long WINAPI PICC_Reader_API(long ReaderHandle,unsigned char* data,unsigned char* Response_APDU);//Data[0] 0����дAPI,1������API +long WINAPI PICC_Reader_DSFID(long ReaderHandle,unsigned char* data,unsigned char* Response_APDU);//Data[0] 0����дDSFID,1������DSFID +long WINAPI PICC_Reader_LockDataBlock(long ReaderHandle,unsigned char blk_add,unsigned char* Response_APDU);//�������������ݡ�ע�⣺�˹��̲����棨���ܽ����������������ݲ������޸ġ� +long WINAPI PICC_Reader_SystemInfor(long ReaderHandle,unsigned char *Response_APDU);//���ڵõ�������ϸ��Ϣ + + +long WINAPI ICC_Reader_ICData(long ReaderHandle,char * Name, char * CardNo, char * ID , char* ksbm,char * gmbb); +long WINAPI hs_ReadMFEF06(HANDLE icdev,char *IDnum,char *name,char *exname,char *sex,char *nation,char *addr,char *birthday); +long WINAPI hs_ReadMFEF05(HANDLE icdev,char *pincode,char *cardtype,char *version,char *orgnum,char *starttime,char *endtime,char *cardnum); + +long WINAPI ReadSiHB(long ReaderHandle , char* SiCode,char*Ver,char*CardNo,char*IdNo,char* Name,char*Sex); +long WINAPI PICC_Reader_SSCardSZID(long ReaderHandle , char* pIDNum ); +long WINAPI PICC_Reader_SFZID(long ReaderHandle, char *pCertNo,char * pErrMsg); +long WINAPI PICC_Reader_selectType(long ReaderHandle,char* TypeID); +long WINAPI ICC_ScanCode(long ReaderHandle, unsigned char*pCodeInfo, int outTine); +long WINAPI iReadCardBas(int iType, char* pOutInfo); +long WINAPI iReadCardBas_HSM_Step1(int iType, char* pOutInfo); +long WINAPI iReadCardBas_HSM_Step2(char *pKey, char* pOutInfo); +long WINAPI iGetDevUID(char *pOutInfo); +long WINAPI ICC_SelscetScan(long ReaderHandle, unsigned char*pCodeInfo , int * lent); +long WINAPI ICC_StopSelscetScan(long ReaderHandle); +long WINAPI PICC_IDCard_Read(long ReaderHandle,const char *pcBmpPath, char *pcTypeID, char *Info, char *pcErrMsg); + + +int WINAPI iOpenPort( char * pErrMsg); +int WINAPI iClosePort(char* pErrMsg); +int WINAPI iReadPin (int pCtrlType,int outtime, char* pErrMsg ,char *pInputPin); + +long WINAPI ixunReader(char *pInputPin); +long WINAPI PICC_Reader_ReadIDCard(long ReaderHandle,char * msg); +int WINAPI GetCardType(); +int WINAPI GetName(char * Info); +int WINAPI GetSex(char * Info); +int WINAPI GetNation(char * Info); +int WINAPI GetBirth(char * Info); +int WINAPI GetAddress(char * Info); +int WINAPI GetCertNo(char * Info); +int WINAPI GetDepartemt(char * Info); +int WINAPI GetEffectDate(char * Info); +int WINAPI GetExpireDate(char * Info); +int WINAPI GetBmpFileData(char * Info); +int WINAPI GetBmpFile(char* pBmpfilepath); +int WINAPI IsFingerExist(); +int WINAPI GetFingerprint(unsigned char* fpInfo); +int WINAPI GetEnName(char * Info); +int WINAPI GetNationalityCode(char * Info); +int WINAPI GetTXZHM(char * Info); +int WINAPI GetTXZQFCS(char * Info); +int WINAPI GetHZCS(char * Info); + + +int WINAPI OpenReader(int a1); +int WINAPI CloseReader(); +int WINAPI CardRest(int a1, char * a2, int *a3); +int WINAPI SendCmd(int a1, char *a2, char *a3); +bool WINAPI CardHalt(); +int WINAPI ReadIDPic(int a1, char * a2); +int WINAPI HD_PosBeep(int a1); + +/*********************���п�*************************************/ +int ICC_GetInfo(long ReaderHandle,int nType,char *TagList, char *AIDList,char *UserInfo); +int ICC_GetTxDetail(long ReaderHandle,int nType,char *AIDList,char *TrDtail); +int ICC_GenARQC(long ReaderHandle,int nType ,char *TxData,char *AIDList,char *ARQCLen,char *ascARQC,char *hexARQC); +int ICC_ARPC_ExeICScript(long ReaderHandle,int nType,char *TxData,char *ARPCLen, char *hexARPC,char *Status,char *TC, char *ScriptResult); + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/main/resources/win32-x86-64/SSSE32.lib b/src/main/resources/win32-x86-64/SSSE32.lib new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/win32-x86-64/autoreplyprint.dll b/src/main/resources/win32-x86-64/autoreplyprint.dll new file mode 100644 index 0000000..46f232f Binary files /dev/null and b/src/main/resources/win32-x86-64/autoreplyprint.dll differ diff --git a/src/main/resources/win32-x86-64/autoreplyprint.exp b/src/main/resources/win32-x86-64/autoreplyprint.exp new file mode 100644 index 0000000..7704d7f Binary files /dev/null and b/src/main/resources/win32-x86-64/autoreplyprint.exp differ diff --git a/src/main/resources/win32-x86-64/autoreplyprint.h b/src/main/resources/win32-x86-64/autoreplyprint.h new file mode 100644 index 0000000..49aea2c --- /dev/null +++ b/src/main/resources/win32-x86-64/autoreplyprint.h @@ -0,0 +1,3405 @@ + +#ifndef AUTOREPLYPRINT_H +#define AUTOREPLYPRINT_H + +//AUTOREPLYPRINT_API +#ifdef _MSC_VER + #ifdef AUTOREPLYPRINT_EXPORTS + #ifndef AUTOREPLYPRINT_API + #define AUTOREPLYPRINT_API __declspec(dllexport) + #endif + #else + #ifndef AUTOREPLYPRINT_API + #define AUTOREPLYPRINT_API __declspec(dllimport) + #endif + #endif +#else + #ifndef AUTOREPLYPRINT_API + #define AUTOREPLYPRINT_API + #endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef enum CP_ComDataBits { CP_ComDataBits_4 = 4, CP_ComDataBits_5 = 5, CP_ComDataBits_6 = 6, CP_ComDataBits_7 = 7, CP_ComDataBits_8 = 8 } CP_ComDataBits; + + +typedef enum CP_ComParity { CP_ComParity_NoParity, CP_ComParity_OddParity, CP_ComParity_EvenParity, CP_ComParity_MarkParity, CP_ComParity_SpaceParity } CP_ComParity; + + +typedef enum CP_ComStopBits { CP_ComStopBits_One, CP_ComStopBits_OnePointFive, CP_ComStopBits_Two } CP_ComStopBits; + + +typedef enum CP_ComFlowControl { CP_ComFlowControl_None, CP_ComFlowControl_XonXoff, CP_ComFlowControl_RtsCts, CP_ComFlowControl_DtrDsr } CP_ComFlowControl; + + +typedef enum CP_CharacterSet { + CP_CharacterSet_USA = 0, + CP_CharacterSet_FRANCE = 1, + CP_CharacterSet_GERMANY = 2, + CP_CharacterSet_UK = 3, + CP_CharacterSet_DENMARK_I = 4, + CP_CharacterSet_SWEDEN = 5, + CP_CharacterSet_ITALY = 6, + CP_CharacterSet_SPAIN_I = 7, + CP_CharacterSet_JAPAN = 8, + CP_CharacterSet_NORWAY = 9, + CP_CharacterSet_DENMARK_II = 10, + CP_CharacterSet_SPAIN_II = 11, + CP_CharacterSet_LATIN = 12, + CP_CharacterSet_KOREA = 13, + CP_CharacterSet_SLOVENIA = 14, + CP_CharacterSet_CHINA = 15 +} CP_CharacterSet; + + +typedef enum CP_CharacterCodepage { + CP_CharacterCodepage_CP437 = 0, + CP_CharacterCodepage_KATAKANA = 1, + CP_CharacterCodepage_CP850 = 2, + CP_CharacterCodepage_CP860 = 3, + CP_CharacterCodepage_CP863 = 4, + CP_CharacterCodepage_CP865 = 5, + CP_CharacterCodepage_WCP1251 = 6, + CP_CharacterCodepage_CP866 = 7, + CP_CharacterCodepage_MIK = 8, + CP_CharacterCodepage_CP755 = 9, + CP_CharacterCodepage_IRAN = 10, + CP_CharacterCodepage_CP862 = 15, + CP_CharacterCodepage_WCP1252 = 16, + CP_CharacterCodepage_WCP1253 = 17, + CP_CharacterCodepage_CP852 = 18, + CP_CharacterCodepage_CP858 = 19, + CP_CharacterCodepage_IRAN_II = 20, + CP_CharacterCodepage_LATVIAN = 21, + CP_CharacterCodepage_CP864 = 22, + CP_CharacterCodepage_ISO_8859_1 = 23, + CP_CharacterCodepage_CP737 = 24, + CP_CharacterCodepage_WCP1257 = 25, + CP_CharacterCodepage_THAI = 26, + CP_CharacterCodepage_CP720 = 27, + CP_CharacterCodepage_CP855 = 28, + CP_CharacterCodepage_CP857 = 29, + CP_CharacterCodepage_WCP1250 = 30, + CP_CharacterCodepage_CP775 = 31, + CP_CharacterCodepage_WCP1254 = 32, + CP_CharacterCodepage_WCP1255 = 33, + CP_CharacterCodepage_WCP1256 = 34, + CP_CharacterCodepage_WCP1258 = 35, + CP_CharacterCodepage_ISO_8859_2 = 36, + CP_CharacterCodepage_ISO_8859_3 = 37, + CP_CharacterCodepage_ISO_8859_4 = 38, + CP_CharacterCodepage_ISO_8859_5 = 39, + CP_CharacterCodepage_ISO_8859_6 = 40, + CP_CharacterCodepage_ISO_8859_7 = 41, + CP_CharacterCodepage_ISO_8859_8 = 42, + CP_CharacterCodepage_ISO_8859_9 = 43, + CP_CharacterCodepage_ISO_8859_15 = 44, + CP_CharacterCodepage_THAI_2 = 45, + CP_CharacterCodepage_CP856 = 46, + CP_CharacterCodepage_CP874 = 47, + CP_CharacterCodepage_TCVN3 = 48 +} CP_CharacterCodepage; + + +typedef enum CP_MultiByteEncoding { CP_MultiByteEncoding_GBK = 0, CP_MultiByteEncoding_UTF8 = 1, CP_MultiByteEncoding_BIG5 = 3, CP_MultiByteEncoding_ShiftJIS = 4, CP_MultiByteEncoding_EUCKR = 5 } CP_MultiByteEncoding; + + +typedef enum CP_ImageBinarizationMethod { CP_ImageBinarizationMethod_Dithering, CP_ImageBinarizationMethod_Thresholding, CP_ImageBinarizationMethod_ErrorDiffusion } CP_ImageBinarizationMethod; + + +typedef enum CP_ImageCompressionMethod { CP_ImageCompressionMethod_None, CP_ImageCompressionMethod_Level1, CP_ImageCompressionMethod_Level2 } CP_ImageCompressionMethod; + + +typedef enum CP_ImagePixelsFormat { + CP_ImagePixelsFormat_MONO = 1, + CP_ImagePixelsFormat_MONOLSB = 2, + CP_ImagePixelsFormat_GRAY8 = 3, + CP_ImagePixelsFormat_BYTEORDERED_RGB24 = 4, + CP_ImagePixelsFormat_BYTEORDERED_BGR24 = 5, + CP_ImagePixelsFormat_BYTEORDERED_ARGB32 = 6, + CP_ImagePixelsFormat_BYTEORDERED_RGBA32 = 7, + CP_ImagePixelsFormat_BYTEORDERED_ABGR32 = 8, + CP_ImagePixelsFormat_BYTEORDERED_BGRA32 = 9 +} CP_ImagePixelsFormat; + + +typedef enum CP_QRCodeECC { CP_QRCodeECC_L = 1, CP_QRCodeECC_M = 2, CP_QRCodeECC_Q = 3, CP_QRCodeECC_H = 4 } CP_QRCodeECC; + + +typedef enum CP_Pos_Alignment { CP_Pos_Alignment_Left, CP_Pos_Alignment_HCenter, CP_Pos_Alignment_Right } CP_Pos_Alignment; + + +typedef enum CP_Pos_BarcodeType { + CP_Pos_BarcodeType_UPCA = 0x41, + CP_Pos_BarcodeType_UPCE = 0x42, + CP_Pos_BarcodeType_EAN13 = 0x43, + CP_Pos_BarcodeType_EAN8 = 0x44, + CP_Pos_BarcodeType_CODE39 = 0x45, + CP_Pos_BarcodeType_ITF = 0x46, + CP_Pos_BarcodeType_CODEBAR = 0x47, + CP_Pos_BarcodeType_CODE93 = 0x48, + CP_Pos_BarcodeType_CODE128 = 0x49 +} CP_Pos_BarcodeType; + + +typedef enum CP_Pos_BarcodeTextPrintPosition { CP_Pos_BarcodeTextPrintPosition_None, CP_Pos_BarcodeTextPrintPosition_AboveBarcode, CP_Pos_BarcodeTextPrintPosition_BelowBarcode, CP_Pos_BarcodeTextPrintPosition_AboveAndBelowBarcode } CP_Pos_BarcodeTextPrintPosition; + + +typedef enum CP_Page_DrawDirection { CP_Page_DrawDirection_LeftToRight, CP_Page_DrawDirection_BottomToTop, CP_Page_DrawDirection_RightToLeft, CP_Page_DrawDirection_TopToBottom } CP_Page_DrawDirection; + + // Page mode draw functions (CP_Page_DrawXXX) + // Horizontal and vertical coordinates can be specified as -1 -2 -3 to indicate that the print is aligned +#ifndef MarcoDefinitionCPPageDrawAlignment +#define MarcoDefinitionCPPageDrawAlignment +#define CP_Page_DrawAlignment_Left -1 +#define CP_Page_DrawAlignment_HCenter -2 +#define CP_Page_DrawAlignment_Right -3 +#define CP_Page_DrawAlignment_Top -1 +#define CP_Page_DrawAlignment_VCenter -2 +#define CP_Page_DrawAlignment_Bottom -3 +#endif + + +typedef enum CP_Label_BarcodeType { + CP_Label_BarcodeType_UPCA = 0, + CP_Label_BarcodeType_UPCE = 1, + CP_Label_BarcodeType_EAN13 = 2, + CP_Label_BarcodeType_EAN8 = 3, + CP_Label_BarcodeType_CODE39 = 4, + CP_Label_BarcodeType_ITF = 5, + CP_Label_BarcodeType_CODEBAR = 6, + CP_Label_BarcodeType_CODE93 = 7, + CP_Label_BarcodeType_CODE128 = 8, + CP_Label_BarcodeType_CODE11 = 9, + CP_Label_BarcodeType_MSI = 10, + CP_Label_BarcodeType_128M = 11, + CP_Label_BarcodeType_EAN128 = 12, + CP_Label_BarcodeType_25C = 13, + CP_Label_BarcodeType_39C = 14, + CP_Label_BarcodeType_39 = 15, + CP_Label_BarcodeType_EAN13PLUS2 = 16, + CP_Label_BarcodeType_EAN13PLUS5 = 17, + CP_Label_BarcodeType_EAN8PLUS2 = 18, + CP_Label_BarcodeType_EAN8PLUS5 = 19, + CP_Label_BarcodeType_POST = 20, + CP_Label_BarcodeType_UPCAPLUS2 = 21, + CP_Label_BarcodeType_UPCAPLUS5 = 22, + CP_Label_BarcodeType_UPCEPLUS2 = 23, + CP_Label_BarcodeType_UPCEPLUS5 = 24, + CP_Label_BarcodeType_CPOST = 25, + CP_Label_BarcodeType_MSIC = 26, + CP_Label_BarcodeType_PLESSEY = 27, + CP_Label_BarcodeType_ITF14 = 28, + CP_Label_BarcodeType_EAN14 = 29 +} CP_Label_BarcodeType; + + +typedef enum CP_Label_BarcodeTextPrintPosition { CP_Label_BarcodeTextPrintPosition_None, CP_Label_BarcodeTextPrintPosition_AboveBarcode, CP_Label_BarcodeTextPrintPosition_BelowBarcode, CP_Label_BarcodeTextPrintPosition_AboveAndBelowBarcode } CP_Label_BarcodeTextPrintPosition; + + +typedef enum CP_Label_Rotation { CP_Label_Rotation_0, CP_Label_Rotation_90, CP_Label_Rotation_180, CP_Label_Rotation_270 } CP_Label_Rotation; + + +typedef enum CP_Label_Color { CP_Label_Color_White, CP_Label_Color_Black } CP_Label_Color; + + // ERROR_CUTTER + // Cutter error + // ERROR_FLASH + // FLASH error + // ERROR_NOPAPER + // No paper + // ERROR_VOLTAGE + // Voltage error + // ERROR_MARKER + // Black mark or seam mark error detected + // ERROR_ENGINE + // Unrecognized printer engine + // ERROR_OVERHEAT + // Overheat + // ERROR_COVERUP + // Open cover or shaft not pressed down + // ERROR_MOTOR + // Motor out of step (usually paper jam) + // INFO_LABELPAPER + // Current paper identified as label paper (0 is continuous paper) + // INFO_LABELMODE + // Currently in label mode + // INFO_HAVEDATA + // We have data to start processing + // INFO_NOPAPERCANCELED + // The last document was cancelled after it was short of paper + // INFO_PAPERNOFETCH + // The documents were not taken + // INFO_PRINTIDLE + // Current print idle + // INFO_RECVIDLE + // The current receive buffer is empty +#ifndef MarcoDefinitionCPPrinterStatus +#define MarcoDefinitionCPPrinterStatus +#define CP_PRINTERSTATUS_ERROR_CUTTER(error_status) (error_status & 0x01) +#define CP_PRINTERSTATUS_ERROR_FLASH(error_status) (error_status & 0x02) +#define CP_PRINTERSTATUS_ERROR_NOPAPER(error_status) (error_status & 0x04) +#define CP_PRINTERSTATUS_ERROR_VOLTAGE(error_status) (error_status & 0x08) +#define CP_PRINTERSTATUS_ERROR_MARKER(error_status) (error_status & 0x10) +#define CP_PRINTERSTATUS_ERROR_ENGINE(error_status) (error_status & 0x20) +#define CP_PRINTERSTATUS_ERROR_OVERHEAT(error_status) (error_status & 0x40) +#define CP_PRINTERSTATUS_ERROR_COVERUP(error_status) (error_status & 0x80) +#define CP_PRINTERSTATUS_ERROR_MOTOR(error_status) (error_status & 0x100) +#define CP_PRINTERSTATUS_INFO_LABELPAPER(info_status) (info_status & 0x02) +#define CP_PRINTERSTATUS_INFO_LABELMODE(info_status) (info_status & 0x04) +#define CP_PRINTERSTATUS_INFO_HAVEDATA(info_status) (info_status & 0x08) +#define CP_PRINTERSTATUS_INFO_NOPAPERCANCELED(info_status) (info_status & 0x10) +#define CP_PRINTERSTATUS_INFO_PAPERNOFETCH(info_status) (info_status & 0x20) +#define CP_PRINTERSTATUS_INFO_PRINTIDLE(info_status) (info_status & 0x40) +#define CP_PRINTERSTATUS_INFO_RECVIDLE(info_status) (info_status & 0x80) +#endif + + // The real-time state here is four bytes + // From low byte to high byte corresponds to these four instructions in the instruction set: + // 10 04 01 + // 10 04 02 + // 10 04 03 + // 10 04 04 + // For some models, due to customization or other reasons, the definition of state value may be inconsistent with here, subject to the actual measurement + // + // DRAWER_OPENED + // Drawer Opened + // OFFLINE + // Offline + // COVERUP + // Cover UP + // FEED_PRESSED + // Feed Pressed + // NOPAPER + // No Paper + // ERROR_OCCURED + // Error Occured + // CUTTER_ERROR + // Cutter Error + // UNRECOVERABLE_ERROR + // Unrecoverable Error + // DEGREE_OR_VOLTAGE_OVERRANGE + // Degree or voltage error + // PAPER_NEAREND + // Paper Near End + // PAPER_TAKEOUT + // Paper takeout +#ifndef MarcoDefinitionCPRTStatus +#define MarcoDefinitionCPRTStatus +#define CP_RTSTATUS_DRAWER_OPENED(status) (((status >> 0) & 0x04) == 0x00) +#define CP_RTSTATUS_OFFLINE(status) (((status >> 0) & 0x08) == 0x08) +#define CP_RTSTATUS_COVERUP(status) (((status >> 8) & 0x04) == 0x04) +#define CP_RTSTATUS_FEED_PRESSED(status) (((status >> 8) & 0x08) == 0x08) +#define CP_RTSTATUS_NOPAPER(status) (((status >> 8) & 0x20) == 0x20) +#define CP_RTSTATUS_ERROR_OCCURED(status) (((status >> 8) & 0x40) == 0x40) +#define CP_RTSTATUS_CUTTER_ERROR(status) (((status >> 16) & 0x08) == 0x08) +#define CP_RTSTATUS_UNRECOVERABLE_ERROR(status) (((status >> 16) & 0x20) == 0x20) +#define CP_RTSTATUS_DEGREE_OR_VOLTAGE_OVERRANGE(status) (((status >> 16) & 0x40) == 0x40) +#define CP_RTSTATUS_PAPER_NEAREND(status) (((status >> 24) & 0x0C) == 0x0C) +#define CP_RTSTATUS_PAPER_TAKEOUT(status) (((status >> 24) & 0x04) == 0x04) +#endif + + +#ifndef MarcoDefinitionCPLabelTextStyle +#define MarcoDefinitionCPLabelTextStyle +#define CP_LABEL_TEXT_STYLE_BOLD (1<<0) +#define CP_LABEL_TEXT_STYLE_UNDERLINE (1<<1) +#define CP_LABEL_TEXT_STYLE_HIGHLIGHT (1<<2) +#define CP_LABEL_TEXT_STYLE_STRIKETHROUGH (1<<3) +#define CP_LABEL_TEXT_STYLE_ROTATION_0 (0<<4) +#define CP_LABEL_TEXT_STYLE_ROTATION_90 (1<<4) +#define CP_LABEL_TEXT_STYLE_ROTATION_180 (2<<4) +#define CP_LABEL_TEXT_STYLE_ROTATION_270 (3<<4) +#define CP_LABEL_TEXT_STYLE_WIDTH_ENLARGEMENT(n) ((n)<<8) +#define CP_LABEL_TEXT_STYLE_HEIGHT_ENLARGEMENT(n) ((n)<<12) +#endif + + +typedef void (*CP_OnNetPrinterDiscovered)(const char *local_ip, const char *discovered_mac, const char *discovered_ip, const char *discovered_name, const void *private_data); + + +typedef void (*CP_OnBluetoothDeviceDiscovered)(const char *device_name, const char *device_address, const void *private_data); + + +typedef void (*CP_OnWiFiP2PDeviceDiscovered)(const char *device_name, const char *device_address, const char *device_type, const void *private_data); + + +typedef void (*CP_OnPortOpenedEvent)(void *handle, const char *name, void *private_data); + + +typedef void (*CP_OnPortOpenFailedEvent)(void *handle, const char *name, void *private_data); + + +typedef void (*CP_OnPortClosedEvent)(void *handle, void *private_data); + + +typedef void (*CP_OnPortWrittenEvent)(void *handle, const unsigned char *buffer, unsigned int count, void *private_data); + + +typedef void (*CP_OnPortReceivedEvent)(void *handle, const unsigned char *buffer, unsigned int count, void *private_data); + + +typedef void (*CP_OnPrinterStatusEvent)(void *handle, const long long printer_error_status, const long long printer_info_status, void *private_data); + + +typedef void (*CP_OnPrinterReceivedEvent)(void *handle, const unsigned int printer_received_byte_count, void *private_data); + + +typedef void (*CP_OnPrinterPrintedEvent)(void *handle, const unsigned int printer_printed_page_id, void *private_data); + + // get library version string + // + // return + // return library version string +AUTOREPLYPRINT_API const char *CP_Library_Version(void); + + // Enumerate serial port + // + // pBuf + // The buffer to save enumerated port list + // + // cbBuf + // The buffer size + // + // pcbNeeded + // The buffer bytes needed + // + // return + // Enumerated port count +AUTOREPLYPRINT_API unsigned int CP_Port_EnumCom(char *pBuf, unsigned int cbBuf, unsigned int *pcbNeeded); + + // Enumerate parallel port + // + // pBuf + // The buffer to save enumerated port list + // + // cbBuf + // The buffer size + // + // pcbNeeded + // The buffer bytes needed + // + // return + // Enumerated port count +AUTOREPLYPRINT_API unsigned int CP_Port_EnumLpt(char *pBuf, unsigned int cbBuf, unsigned int *pcbNeeded); + + // Enumerate usb port + // + // pBuf + // The buffer to save enumerated port list + // + // cbBuf + // The buffer size + // + // pcbNeeded + // The buffer bytes needed + // + // return + // Enumerated port count +AUTOREPLYPRINT_API unsigned int CP_Port_EnumUsb(char *pBuf, unsigned int cbBuf, unsigned int *pcbNeeded); + + // Enumerate net printer + // + // timeout + // enumrate timeout ms + // + // cancel + // cancel bit, if value is non-zero, enum process will exit. + // + // on_discovered + // enumrated callback function + // + // private_data + // the parameter passed to callback function + // + // return + // none +AUTOREPLYPRINT_API void CP_Port_EnumNetPrinter(unsigned int timeout, int *cancel, CP_OnNetPrinterDiscovered on_discovered, const void *private_data); + + // Enumerate bt printer + // + // on_discovered + // enumrated callback function + // + // private_data + // the parameter passed to callback function + // + // return + // none +AUTOREPLYPRINT_API void CP_Port_EnumBtDevice(unsigned int timeout, int *cancel, CP_OnBluetoothDeviceDiscovered on_discovered, const void *private_data); + + // Enumerate BLE printer + // + // on_discovered + // enumrated callback function + // + // private_data + // the parameter passed to callback function + // + // return + // none +AUTOREPLYPRINT_API void CP_Port_EnumBleDevice(unsigned int timeout, int *cancel, CP_OnBluetoothDeviceDiscovered on_discovered, const void *private_data); + + // Enumerate WiFi P2P printer + // + // on_discovered + // enumrated callback function + // + // private_data + // the parameter passed to callback function + // + // return + // none +AUTOREPLYPRINT_API void CP_Port_EnumWiFiP2PDevice(unsigned int timeout, int *cancel, CP_OnWiFiP2PDeviceDiscovered on_discovered, const void *private_data); + + // Open com port + // + // name + // port name + // for example COM1,COM2,COM3,...COM11... + // + // baudrate + // baudrate + // Normally choose 9600,19200,38400,57600,115200. + // Need to keep the same as printer baudrate, suggest using high baudrate to get better printing speed. + // + // databits + // databits, value range is [4,8] + // + // parity + // Parity bit, The values are defined as follows: + // value define + // 0 no parity + // 1 odd parity + // 2 even parity + // 3 mark parity + // 4 space parity + // + // stopbits + // Parity bit, The values are defined as follows: + // value define + // 0 1bit stopbits + // 1 1.5bit stopbits + // 2 2bit stopbits + // + // flowcontrol + // flow control + // + // autoreplymode + // 0 don't start autoreplymode + // 1 start autoreplymode + // attention: + // Only some models support automatic return mode, please ask the seller if you support it + // After the automatic return mode is enabled, the printer will return the status automatically + // The state of the printer cannot be automatically obtained if it is not started + // + // return + // Return handle, If open success, return non-zero value, else return zero. + // + // remarks + // If serial port was occupied, open serial will fail + // If baud rate don't match with printer baud rate, it won't print. +AUTOREPLYPRINT_API void *CP_Port_OpenCom(const char *name, unsigned int baudrate, CP_ComDataBits databits, CP_ComParity parity, CP_ComStopBits stopbits, CP_ComFlowControl flowcontrol, int autoreplymode); + + // Open Lpt + // + // name + // port name + // for example: LPT1,LPT2,LPT3... + // + // return + // Return handle, If open success, return non-zero value, else return zero. + // + // remarks + // Parallel port just support one way communication, just can write, but can't read + // All the query status function, are invalid for parallel port. +AUTOREPLYPRINT_API void *CP_Port_OpenLpt(const char *name); + + // Open USB + // + // name + // port name + // Can get printer name through Port_EnumUSB + // Can use any other strings, at this time, if find USB printer, will open directly. + // + // autoreplymode + // 0 don't start autoreplymode + // 1 start autoreplymode + // attention: + // Only some models support automatic return mode, please ask the seller if you support it + // After the automatic return mode is enabled, the printer will return the status automatically + // The state of the printer cannot be automatically obtained if it is not started + // + // return + // Return handle, If open success, return non-zero value, else return zero. + // + // remarks + // USB printer connect to computer, if device manager appear USB Printing Support, then can open USE this function. +AUTOREPLYPRINT_API void *CP_Port_OpenUsb(const char *name, int autoreplymode); + + // Open Tcp + // + // local_ip + // Bind to local IP + // For multiple network CARDS or multiple local ips, select the specified IP + // Passing in a 0 indicates that it is not specified + // + // dest_ip + // IP Addres or printer name + // For example: 192.168.1.87 + // + // dest_port + // Port Number + // Fixed value: 9100 + // + // timeout + // connect timeout + // + // autoreplymode + // 0 don't start autoreplymode + // 1 start autoreplymode + // attention: + // Only some models support automatic return mode, please ask the seller if you support it + // After the automatic return mode is enabled, the printer will return the status automatically + // The state of the printer cannot be automatically obtained if it is not started + // + // return + // Return handle, If open success, return non-zero value, else return zero. + // + // remarks + // PC and printer need in the same network segment, so they can connect +AUTOREPLYPRINT_API void *CP_Port_OpenTcp(const char *local_ip, const char *dest_ip, unsigned short dest_port, unsigned int timeout, int autoreplymode); + + // Connect Bluetooth Printer Via SPP + // + // address + // bluetooth address + // + // autoreplymode + // 0 don't start autoreplymode + // 1 start autoreplymode + // attention: + // Only some models support automatic return mode, please ask the seller if you support it + // After the automatic return mode is enabled, the printer will return the status automatically + // The state of the printer cannot be automatically obtained if it is not started + // + // return + // Return handle, If open success, return non-zero value, else return zero. + // + // remarks + // only for android +AUTOREPLYPRINT_API void *CP_Port_OpenBtSpp(const char *address, int autoreplymode); + + // Connect Bluetooth Printer Via BLE + // + // address + // bluetooth address + // + // autoreplymode + // 0 don't start autoreplymode + // 1 start autoreplymode + // attention: + // Only some models support automatic return mode, please ask the seller if you support it + // After the automatic return mode is enabled, the printer will return the status automatically + // The state of the printer cannot be automatically obtained if it is not started + // + // return + // Return handle, If open success, return non-zero value, else return zero. + // + // remarks + // only for android,ios,macos +AUTOREPLYPRINT_API void *CP_Port_OpenBtBle(const char *address, int autoreplymode); + + // Connect Bluetooth Printer Via BLE(Use Special Proto To Transfer Data) + // + // address + // bluetooth address + // + // autoreplymode + // 0 don't start autoreplymode + // 1 start autoreplymode + // attention: + // Only some models support automatic return mode, please ask the seller if you support it + // After the automatic return mode is enabled, the printer will return the status automatically + // The state of the printer cannot be automatically obtained if it is not started + // + // return + // Return handle, If open success, return non-zero value, else return zero. + // + // remarks + // only for ios,macos +AUTOREPLYPRINT_API void *CP_Port_OpenBtBleProtoV2(const char *address, int autoreplymode); + + // Creates a memory buffer that all subsequent print instructions are written to + // + // buffer_size + // buffer size + // + // return + // Return handle, If open success, return non-zero value, else return zero. + // + // remarks + // This can be used in the following two scenarios + // scenario one: + // A single document needs to send more than one instruction, and you want to put all the instructions together and send them to the printer at once to improve the transmission speed + // scenario two: + // Sometimes you need to know exactly what a function is sending, you need to know exactly what data is being sent, right +AUTOREPLYPRINT_API void *CP_Port_OpenMemoryBuffer(unsigned int buffer_size); + + // get memory buffer data pointer + // + // handle + // Port handle, returned by OpenXXX + // + // return + // return memory buffer data pointer. or return zero means failed +AUTOREPLYPRINT_API unsigned char *CP_Port_GetMemoryBufferDataPointer(void *handle); + + // get memory buffer data length + // + // handle + // Port handle, returned by OpenXXX + // + // return + // return memory buffer data length +AUTOREPLYPRINT_API unsigned int CP_Port_GetMemoryBufferDataLength(void *handle); + + // Clear memory buffer data + // + // handle + // Port handle, returned by OpenXXX + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_ClearMemoryBufferData(void *handle); + + // Connect WiFi P2P Printer + // + // address + // printer address + // for example: "01:02:03:04:05:06" + // + // timeout + // connect timeout ms, you can set to 10000 + // + // return + // return printer IP address (network byte ordered) + // If open success, return non-zero value, else return zero. + // + // remarks + // only for android +AUTOREPLYPRINT_API int CP_Port_WiFiP2P_Connect(const char *device_address, unsigned int timeout); + + // Disconnect WiFi P2P Connection +AUTOREPLYPRINT_API void CP_Port_WiFiP2P_Disconnect(); + + // Check WiFi P2P Is Connected + // + // return + // if connected, return true. + // if not connected, return false. +AUTOREPLYPRINT_API int CP_Port_WiFiP2P_IsConnected(); + + // Write data to port + // + // handle + // Port handle, returned by OpenXXX + // + // buffer + // buffer + // + // count + // buffer length + // + // timeout + // Timeout ms + // + // return + // return bytes writted. or return -1 means failed +AUTOREPLYPRINT_API int CP_Port_Write(void *handle, const unsigned char *buffer, unsigned int count, unsigned int timeout); + + // Receive data from port + // + // handle + // Port handle, returned by OpenXXX + // + // buffer + // buffer + // + // count + // buffer length + // + // timeout + // Timeout ms + // + // return + // return bytes readed. or return -1 means failed +AUTOREPLYPRINT_API int CP_Port_Read(void *handle, unsigned char *buffer, unsigned int count, unsigned int timeout); + + // Receive data from port + // + // handle + // Port handle, returned by OpenXXX + // + // buffer + // buffer + // + // count + // buffer length + // + // timeout + // Timeout ms + // + // breakByte + // break read byte + // + // return + // return bytes readed. or return -1 means failed +AUTOREPLYPRINT_API int CP_Port_ReadUntilByte(void *handle, unsigned char *buffer, unsigned int count, unsigned int timeout, unsigned char breakByte); + + // get readable data from port + // + // handle + // Port handle, returned by OpenXXX + // + // return + // return readable. or return -1 means failed +AUTOREPLYPRINT_API int CP_Port_Available(void *handle); + + // Skip receive buffer + // + // handle + // Port handle, returned by OpenXXX + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_SkipAvailable(void *handle); + + // Check Connection Valid + // + // handle + // Port handle, returned by OpenXXX + // + // return + // Returns true if the port is open and the status is continuously updated + // False is returned if the port is not open, closed, or the status is not updated for more than 6 seconds +AUTOREPLYPRINT_API int CP_Port_IsConnectionValid(void *handle); + + // Check Port Is Opened + // + // handle + // Port handle, returned by OpenXXX + // + // return + // Returns true if the port is open and the connection is not broken or closed + // Returns false if the port is not open, or if the connection is broken or closed +AUTOREPLYPRINT_API int CP_Port_IsOpened(void *handle); + + // Close Port + // + // handle + // Port handle, returned by OpenXXX + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_Close(void *handle); + + // Add Callback, Open Port Success + // + // event + // callback function + // + // private_data + // the parameter passed to callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_AddOnPortOpenedEvent(const CP_OnPortOpenedEvent event, void *private_data); + + // Add Callback, Open Port Failed + // + // event + // callback function + // + // private_data + // the parameter passed to callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_AddOnPortOpenFailedEvent(const CP_OnPortOpenFailedEvent event, void *private_data); + + // Add Callback, Port Closed + // + // event + // callback function + // + // private_data + // the parameter passed to callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_AddOnPortClosedEvent(const CP_OnPortClosedEvent event, void *private_data); + + // Add Callback, Port Written Bytes + // + // event + // callback function + // + // private_data + // the parameter passed to callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_AddOnPortWrittenEvent(const CP_OnPortWrittenEvent event, void *private_data); + + // Add Callback, Port Received Bytes + // + // event + // callback function + // + // private_data + // the parameter passed to callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_AddOnPortReceivedEvent(const CP_OnPortReceivedEvent event, void *private_data); + + // Remove Callback + // + // event + // callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_RemoveOnPortOpenedEvent(const CP_OnPortOpenedEvent event); + + // Remove Callback + // + // event + // callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_RemoveOnPortOpenFailedEvent(const CP_OnPortOpenFailedEvent event); + + // Remove Callback + // + // event + // callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_RemoveOnPortClosedEvent(const CP_OnPortClosedEvent event); + + // Remove Callback + // + // event + // callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_RemoveOnPortWrittenEvent(const CP_OnPortWrittenEvent event); + + // Remove Callback + // + // event + // callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Port_RemoveOnPortReceivedEvent(const CP_OnPortReceivedEvent event); + + // Add Callback, Printer Status Updated + // + // event + // callback function + // + // private_data + // the parameter passed to callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_AddOnPrinterStatusEvent(const CP_OnPrinterStatusEvent event, void *private_data); + + // Add Callback, Printer Received Byte Count Updated + // + // event + // callback function + // + // private_data + // the parameter passed to callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_AddOnPrinterReceivedEvent(const CP_OnPrinterReceivedEvent event, void *private_data); + + // Add Callback, Printer Printed Page ID Updated + // + // event + // callback function + // + // private_data + // the parameter passed to callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_AddOnPrinterPrintedEvent(const CP_OnPrinterPrintedEvent event, void *private_data); + + // Remove Callback + // + // event + // callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_RemoveOnPrinterStatusEvent(const CP_OnPrinterStatusEvent event); + + // Remove Callback + // + // event + // callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_RemoveOnPrinterReceivedEvent(const CP_OnPrinterReceivedEvent event); + + // Remove Callback + // + // event + // callback function + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_RemoveOnPrinterPrintedEvent(const CP_OnPrinterPrintedEvent event); + + // Get Printer Resolution Info + // + // handle + // Port handle, returned by OpenXXX + // + // width_mm + // Max Page Width + // + // height_mm + // Max Page Height + // + // dots_per_mm + // Dots Per MM + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_GetPrinterResolutionInfo(void *handle, unsigned int *width_mm, unsigned int *height_mm, unsigned int *dots_per_mm); + + // Get Printer Firmware Version + // + // handle + // Port handle, returned by OpenXXX + // + // pBuf + // The buffer + // + // cbBuf + // The buffer size + // + // pcbNeeded + // The buffer bytes needed + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_GetPrinterFirmwareVersion(void *handle, char *pBuf, unsigned int cbBuf, unsigned int *pcbNeeded); + + // Get Printer Status + // + // handle + // Port handle, returned by OpenXXX + // + // printer_error_status + // Printer Error Status + // + // printer_info_status + // Printer Info Status + // + // timestamp_ms + // timestamp + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_GetPrinterStatusInfo(void *handle, long long *printer_error_status, long long *printer_info_status, long long *timestamp_ms); + + // Get Printer Received Byte Count + // + // handle + // Port handle, returned by OpenXXX + // + // printer_received_byte_count + // Printer Received Byte Count + // + // timestamp_ms + // timestamp + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_GetPrinterReceivedInfo(void *handle, unsigned int *printer_received_byte_count, long long *timestamp_ms); + + // Get Printer Printed Page ID + // + // handle + // Port handle, returned by OpenXXX + // + // printer_printed_page_id + // Printer Printed Page ID + // + // timestamp_ms + // timestamp + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_GetPrinterPrintedInfo(void *handle, unsigned int *printer_printed_page_id, long long *timestamp_ms); + + // Get Printer Label Position Adjustment + // + // handle + // Port handle, returned by OpenXXX + // + // label_print_position_adjustment + // Printer label print position adjustment + // + // label_tear_position_adjustment + // Printer label tear position adjustment + // + // timestamp_ms + // timestamp + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_GetPrinterLabelPositionAdjustmentInfo(void *handle, double *label_print_position_adjustment, double *label_tear_position_adjustment, long long *timestamp_ms); + + // adjust label print position and tear paper position + // + // handle + // Port handle, returned by OpenXXX + // + // label_print_position_adjustment + // Label print position adjustment mm (adjustment can not exceed [-4,4]) + // + // label_tear_position_adjustment + // Label tear position adjustment mm (adjustment can not exceed [-4,4]) + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Printer_SetPrinterLabelPositionAdjustmentInfo(void *handle, double label_print_position_adjustment, double label_tear_position_adjustment); + + // Clear Printer Buffer Runtime + // + // handle + // Port handle, returned by OpenXXX + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_ClearPrinterBuffer(void *handle); + + // Clear Printer Error Runtime + // + // handle + // Port handle, returned by OpenXXX + // + // return + // true on success. + // false on failed. +AUTOREPLYPRINT_API int CP_Printer_ClearPrinterError(void *handle); + + // Query the real-time status of the printer + // If it is a machine that supports automatic return, the state will be returned automatically. No need to use this command to query + // Due to the real-time state instruction, there is no check, the result cannot be guaranteed to be correct + // + // handle + // Port handle, returned by OpenXXX + // + // timeout + // timeout ms + // The wait time for query does not exceed this time + // + // return + // If command is successfully, it returns rtstatus else it returns 0. + // Please check CP_RTSTATUS_XXX for the detailed status. If the status definition is inconsistent with the actual model, the actual measurement shall prevail. +AUTOREPLYPRINT_API int CP_Pos_QueryRTStatus(void *handle, unsigned int timeout); + + // Query the print result of the previous content + // + // handle + // Port handle, returned by OpenXXX + // + // timeout + // timeout ms + // The wait time for query print results does not exceed this time + // + // return + // If print is successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_QueryPrintResult(void *handle, unsigned int timeout); + + // Turn on cashbox + // + // handle + // Port handle, returned by OpenXXX + // + // nDrawerIndex + // Cashbox no, value are defined as follow: + // value define + // 0 Cashbox pin 2 + // 1 Cashbox pin 5 + // + // nHighLevelTime + // Cashbox pulse high potential ms time + // + // nLowLevelTime + // Cashbox pulse low potential ms time + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_KickOutDrawer(void *handle, int nDrawerIndex, int nHighLevelTime, int nLowLevelTime); + + // Buzzer call + // + // handle + // Port handle, returned by OpenXXX + // + // nBeepCount + // Calling times + // + // nBeepMs + // Calling time ms, value range is [100,900], flour to 100 milliseconds. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_Beep(void *handle, int nBeepCount, int nBeepMs); + + // feed to cutter position and half cut paper + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_FeedAndHalfCutPaper(void *handle); + + // full cut paper + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_FullCutPaper(void *handle); + + // half cut paper + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_HalfCutPaper(void *handle); + + // printer feed numLines + // + // handle + // Port handle, returned by OpenXXX + // + // numLines + // number of lines to feed + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_FeedLine(void *handle, int numLines); + + // printer feed numDots + // + // handle + // Port handle, returned by OpenXXX + // + // numDots + // number of dots to feed + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_FeedDot(void *handle, int numDots); + + // printer print self test page + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintSelfTestPage(void *handle); + + // print text + // + // handle + // Port handle, returned by OpenXXX + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintText(void *handle, const char *str); + + // print text + // + // handle + // Port handle, returned by OpenXXX + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to UTF8 encoding. +AUTOREPLYPRINT_API int CP_Pos_PrintTextInUTF8(void *handle, const wchar_t *str); + + // print text + // + // handle + // Port handle, returned by OpenXXX + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to GBK encoding. +AUTOREPLYPRINT_API int CP_Pos_PrintTextInGBK(void *handle, const wchar_t *str); + + // print text + // + // handle + // Port handle, returned by OpenXXX + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to BIG5 encoding. +AUTOREPLYPRINT_API int CP_Pos_PrintTextInBIG5(void *handle, const wchar_t *str); + + // print text + // + // handle + // Port handle, returned by OpenXXX + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to ShiftJIS encoding. +AUTOREPLYPRINT_API int CP_Pos_PrintTextInShiftJIS(void *handle, const wchar_t *str); + + // print text + // + // handle + // Port handle, returned by OpenXXX + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to EUCKR encoding. +AUTOREPLYPRINT_API int CP_Pos_PrintTextInEUCKR(void *handle, const wchar_t *str); + + // print text + // + // handle + // Port handle, returned by OpenXXX + // + // str + // the string to print + // + // len + // the length to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintTextInBytes(void *handle, const char *str, int len); + + // print 1D barcode + // + // handle + // Port handle, returned by OpenXXX + // + // nBarcodeType + // barcode type + // values are defined as follow: + // value type + // 0x41 UPC-A + // 0x42 UPC-E + // 0x43 EAN13 + // 0x44 EAN8 + // 0x45 CODE39 + // 0x46 ITF + // 0x47 CODABAR + // 0x48 CODE93 + // 0x49 CODE128 + // + // str + // the barcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintBarcode(void *handle, CP_Pos_BarcodeType nBarcodeType, const char *str); + + // print Code128 barcode, this function auto change type b and c to print more characters. + // Normally, do not use this function to print CODE128 code + // This function is mainly used for compatibility with some older models + // New models already support automatic switching codes by default + // New models cannot print barcodes using this function + // + // handle + // Port handle, returned by OpenXXX + // + // str + // the barcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintBarcode_Code128Auto(void *handle, const char *str); + + // print qrcode + // + // handle + // Port handle, returned by OpenXXX + // + // nVersion + // Assign charater version. The value range is:[0,16] + // When version is 0, printer caculates version number according to character set automatically. + // + // nECCLevel + // Assign error correction level. + // The value range is: [1, 4]. + // Definitios are as below: + // ECC error correction level + // 1 L:7%, low error correction, much data. + // 2 M:15%, medium error correction + // 3 Q:optimize error correction + // 4 H:30%, the highest error correction, less data. + // + // str + // the qrcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintQRCode(void *handle, int nVersion, CP_QRCodeECC nECCLevel, const char *str); + + // print qrcode + // + // handle + // Port handle, returned by OpenXXX + // + // nQRCodeUnitWidth + // QRCode code block width, the value range is [1, 16] + // + // nECCLevel + // Assign error correction level. + // The value range is: [1, 4]. + // Definitios are as below: + // ECC error correction level + // 1 L:7%, low error correction, much data. + // 2 M:15%, medium error correction + // 3 Q:optimize error correction + // 4 H:30%, the highest error correction, less data. + // + // str + // the qrcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintQRCodeUseEpsonCmd(void *handle, int nQRCodeUnitWidth, CP_QRCodeECC nECCLevel, const char *str); + + // print 2 qrcode + // + // handle + // Port handle, returned by OpenXXX + // + // nQRCodeUnitWidth + // QRCode code block width, the value range is [1, 8] + // + // nQR1Position + // nQR2Position + // QRCode position + // + // nQR1Version + // nQR2Version + // Assign charater version. The value range is:[0,16] + // When version is 0, printer caculates version number according to character set automatically. + // + // nQR1ECCLevel + // nQR2ECCLevel + // Assign error correction level. + // The value range is: [1, 4]. + // Definitios are as below: + // ECC error correction level + // 1 L:7%, low error correction, much data. + // 2 M:15%, medium error correction + // 3 Q:optimize error correction + // 4 H:30%, the highest error correction, less data. + // + // strQR1 + // strQR2 + // the qrcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintDoubleQRCode(void *handle, int nQRCodeUnitWidth, int nQR1Position, int nQR1Version, CP_QRCodeECC nQR1ECCLevel, const char *strQR1, int nQR2Position, int nQR2Version, CP_QRCodeECC nQR2ECCLevel, const char *strQR2); + + // print pdf417 barcode + // + // handle + // Port handle, returned by OpenXXX + // + // columnCount + // column count, range is [0,30] + // + // rowCount + // row count, range is 0,[3,90] + // + // unitWidth + // module unit width, range is [2,8] + // + // rowHeight + // row height, range is [2,8] + // + // nECCLevel + // ecc level, range is [0,8] + // + // dataProcessingMode + // data processing mode, 0 select standard PDF417, 1 select cutoff PDF417 + // + // str + // the pdf417 data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintPDF417BarcodeUseEpsonCmd(void *handle, int columnCount, int rowCount, int unitWidth, int rowHeight, int nECCLevel, int dataProcessingMode, const char *str); + + // print image + // + // handle + // Port handle, returned by OpenXXX + // + // dstw + // the width to print + // + // dsth + // the height to print + // + // pszFile + // image file path + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // compression_method + // print data compress method, values are defined as follow + // value define + // 0 no compress + // 1 compress level 1 + // 2 compress level 2 + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintRasterImageFromFile(void *handle, int dstw, int dsth, const char *pszFile, CP_ImageBinarizationMethod binaryzation_method, CP_ImageCompressionMethod compression_method); + + // print image (data can be readed from file) + // + // handle + // Port handle, returned by OpenXXX + // + // dstw + // the width to print + // + // dsth + // the height to print + // + // data + // image data + // + // data_size + // image data size + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // compression_method + // print data compress method, values are defined as follow + // value define + // 0 no compress + // 1 compress level 1 + // 2 compress level 2 + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintRasterImageFromData(void *handle, int dstw, int dsth, const unsigned char *data, unsigned int data_size, CP_ImageBinarizationMethod binaryzation_method, CP_ImageCompressionMethod compression_method); + + // print image pixels + // + // handle + // Port handle, returned by OpenXXX + // + // img_data + // image pixels data + // + // img_datalen + // image pixels data length + // + // img_width + // image pixel width + // + // img_height + // image pixel height + // + // img_stride + // image horizontal stirde. means bytes per line. + // + // img_format + // image pixel data format, values are defined as follow + // value define + // 1 mono + // 2 monolsb + // 3 gray + // 4 r.g.b in byte-ordered + // 5 b.g.r in byte-ordered + // 6 a.r.g.b in byte-ordered + // 7 r.g.b.a in byte-ordered + // 8 a.b.g.r in byte-ordered + // 9 b.g.r.a in byte-ordered + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // compression_method + // print data compress method, values are defined as follow + // value define + // 0 no compress + // 1 compress level 1 + // 2 compress level 2 + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintRasterImageFromPixels(void *handle, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, CP_ImagePixelsFormat img_format, CP_ImageBinarizationMethod binaryzation_method, CP_ImageCompressionMethod compression_method); + + // print one horizontal line + // + // handle + // Port handle, returned by OpenXXX + // + // nLineStartPosition + // line start position + // + // nLineEndPosition + // line end position + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintHorizontalLine(void *handle, int nLineStartPosition, int nLineEndPosition); + + // print one horizontal line + // + // handle + // Port handle, returned by OpenXXX + // + // nLineStartPosition + // line start position + // + // nLineEndPosition + // line end position + // + // nLineThickness + // line thickness + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintHorizontalLineSpecifyThickness(void *handle, int nLineStartPosition, int nLineEndPosition, int nLineThickness); + + // print multiple horizontal lines at one row, multi call can print curve + // + // handle + // Port handle, returned by OpenXXX + // + // nLineCount + // Line count + // + // pLineStartPosition + // Line start position + // + // pLineEndPosition + // Line end position + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_PrintMultipleHorizontalLinesAtOneRow(void *handle, int nLineCount, int *pLineStartPosition, int *pLineEndPosition); + + // reset printer, clear settings + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_ResetPrinter(void *handle); + + // set print speed (some printer suppert) + // + // handle + // Port handle, returned by OpenXXX + // + // nSpeed + // print speed in mm/s + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetPrintSpeed(void *handle, int nSpeed); + + // set print density (some printer suppert) + // + // handle + // Port handle, returned by OpenXXX + // + // nDensity + // the print density[0,15] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetPrintDensity(void *handle, int nDensity); + + // set printer to single byte mode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetSingleByteMode(void *handle); + + // set character set + // + // handle + // Port handle, returned by OpenXXX + // + // nCharacterSet + // character set, range is [0, 15] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetCharacterSet(void *handle, CP_CharacterSet nCharacterSet); + + // set character codepage + // + // handle + // Port handle, returned by OpenXXX + // + // nCharacterCodepage + // character codepage, range is [0,255] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetCharacterCodepage(void *handle, CP_CharacterCodepage nCharacterCodepage); + + // set printer to multi byte mode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetMultiByteMode(void *handle); + + // set printer multi byte encoding + // + // handle + // Port handle, returned by OpenXXX + // + // nEncoding + // multi byte encoding, values defined as follow: + // value define + // 0 GBK + // 1 UTF8 + // 3 BIG5 + // 4 SHIFT-JIS + // 5 EUC-KR + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetMultiByteEncoding(void *handle, CP_MultiByteEncoding nEncoding); + + // set print movement unit + // + // handle + // Port handle, returned by OpenXXX + // + // nHorizontalMovementUnit + // horizontal movement unit + // + // nVerticalMovementUnit + // vertical movement unit + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // if set movement unit to 200, 1mm means 8point. +AUTOREPLYPRINT_API int CP_Pos_SetMovementUnit(void *handle, int nHorizontalMovementUnit, int nVerticalMovementUnit); + + // set print area left margin + // + // handle + // Port handle, returned by OpenXXX + // + // nLeftMargin + // print area left margin + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetPrintAreaLeftMargin(void *handle, int nLeftMargin); + + // set print area width + // + // handle + // Port handle, returned by OpenXXX + // + // nWidth + // print area width + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetPrintAreaWidth(void *handle, int nWidth); + + // set horizontal absolute print position + // + // handle + // Port handle, returned by OpenXXX + // + // nPosition + // print position + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetHorizontalAbsolutePrintPosition(void *handle, int nPosition); + + // set horizontal relative print position + // + // handle + // Port handle, returned by OpenXXX + // + // nPosition + // print position + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetHorizontalRelativePrintPosition(void *handle, int nPosition); + + // set vertical absolute print position, only valid in page mode. + // + // handle + // Port handle, returned by OpenXXX + // + // nPosition + // print position + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetVerticalAbsolutePrintPosition(void *handle, int nPosition); + + // set vertical relative print position, only valid in page mode. + // + // handle + // Port handle, returned by OpenXXX + // + // nPosition + // print position + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetVerticalRelativePrintPosition(void *handle, int nPosition); + + // set print alignment + // + // handle + // Port handle, returned by OpenXXX + // + // nAlignment + // print alignment, value are defined as follow: + // value define + // 0 align left + // 1 align center + // 2 align right + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetAlignment(void *handle, CP_Pos_Alignment nAlignment); + + // set text scale + // + // handle + // Port handle, returned by OpenXXX + // + // nWidthScale + // width scale + // + // nHeightScale + // height scale + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetTextScale(void *handle, int nWidthScale, int nHeightScale); + + // set ascii text font type + // + // handle + // Port handle, returned by OpenXXX + // + // nFontType + // ascii text font type, values defined as follow: + // value define + // 0 FontA (12x24) + // 1 FontB (9x17) + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetAsciiTextFontType(void *handle, int nFontType); + + // set text bold + // + // handle + // Port handle, returned by OpenXXX + // + // nBold + // text bold , values defined as follow: + // value define + // 0 don't bold + // 1 bold + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetTextBold(void *handle, int nBold); + + // set text underline + // + // handle + // Port handle, returned by OpenXXX + // + // nUnderline + // text underline, values defined as follow: + // value define + // 0 no underline + // 1 1 point underline + // 2 2 point underline + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetTextUnderline(void *handle, int nUnderline); + + // set text upside down + // + // handle + // Port handle, returned by OpenXXX + // + // nUpsideDown + // upside down, values defined as follow: + // value define + // 0 print text dont't upside down + // 1 print text upside down + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetTextUpsideDown(void *handle, int nUpsideDown); + + // set text black and white reverse + // + // handle + // Port handle, returned by OpenXXX + // + // nWhiteOnBlack + // black and white reverse, values defined as follow: + // value define + // 0 print text normal + // 1 print text black and white reverse + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetTextWhiteOnBlack(void *handle, int nWhiteOnBlack); + + // set text rotate 90 print + // + // handle + // Port handle, returned by OpenXXX + // + // nRotate + // set text rotate, value defined as follow: + // value define + // 0 print normal + // 1 text print rotate 90 degree + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetTextRotate(void *handle, int nRotate); + + // set line height + // + // handle + // Port handle, returned by OpenXXX + // + // nLineHeight + // line height, value range is [1,255] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetTextLineHeight(void *handle, int nLineHeight); + + // set ascii text char right spacing + // + // handle + // Port handle, returned by OpenXXX + // + // nSpacing + // right spacing, range is [1,255] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetAsciiTextCharRightSpacing(void *handle, int nSpacing); + + // set kanji text char left spacing and right spacing + // + // handle + // Port handle, returned by OpenXXX + // + // nLeftSpacing + // left spacing, range is [1,255] + // + // nRightSpacing + // right spacing, range is [1,255] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetKanjiTextCharSpacing(void *handle, int nLeftSpacing, int nRightSpacing); + + // set barcode and qrcode unit width + // + // handle + // Port handle, returned by OpenXXX + // + // nBarcodeUnitWidth + // It assigns the code basic element width. range is [2,6] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetBarcodeUnitWidth(void *handle, int nBarcodeUnitWidth); + + // set barcode height + // + // handle + // Port handle, returned by OpenXXX + // + // nBarcodeHeight + // Barcode height, range is [1,255] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetBarcodeHeight(void *handle, int nBarcodeHeight); + + // set barcode readable text font type + // + // handle + // Port handle, returned by OpenXXX + // + // nFontType + // It assigns HRI(Human Readable Interpretation) character font types. + // value type + // 0 standard ASCII + // 1 small ASCII + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetBarcodeReadableTextFontType(void *handle, int nFontType); + + // set barcode readable text print position + // + // handle + // Port handle, returned by OpenXXX + // + // nTextPosition + // barcode readable text position, value range is [0, 3]. + // value defined as follow: + // value define + // 0 don't show readable text + // 1 show readable text below barcode + // 2 show readable text above barcode + // 3 show readable text above and below barcode + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Pos_SetBarcodeReadableTextPosition(void *handle, CP_Pos_BarcodeTextPrintPosition nTextPosition); + + // select page mode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_SelectPageMode(void *handle); + + // select page mode and set movement unit , page area.and other params to default value. + // + // handle + // Port handle, returned by OpenXXX + // + // nHorizontalMovementUnit + // horizontal movement unit + // + // nVerticalMovementUnit + // vertical movement unit + // + // x + // horizontal start position + // + // y + // vertical start position + // + // width + // print area width + // + // height + // print area height + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_SelectPageModeEx(void *handle, int nHorizontalMovementUnit, int nVerticalMovementUnit, int x, int y, int width, int height); + + // exit page mode and enter standard mode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. + // none +AUTOREPLYPRINT_API int CP_Page_ExitPageMode(void *handle); + + // print page in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_PrintPage(void *handle); + + // clear page in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_ClearPage(void *handle); + + // set page area in pagemode, max height is 2000(8 dot per mm) + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal start position + // + // y + // vertical start position + // + // width + // print area width + // + // height + // print area height + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_SetPageArea(void *handle, int x, int y, int width, int height); + + // set print direction in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // nDirection + // print area direction + // 0 left -> right + // 1 bottom -> top + // 2 right -> left + // 3 top -> bottom + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_SetPageDrawDirection(void *handle, CP_Page_DrawDirection nDirection); + + // draw rect in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // width + // rect width + // + // height + // rect height + // + // color + // rect color, 0 means white, 1 means black. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_DrawRect(void *handle, int x, int y, int width, int height, int color); + + // draw box in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // width + // box width + // + // height + // box height + // + // borderwidth + // box border width + // + // bordercolor + // box border color, 0 means white, 1 means black. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_DrawBox(void *handle, int x, int y, int width, int height, int borderwidth, int bordercolor); + + // draw text in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_DrawText(void *handle, int x, int y, const char *str); + + // draw text in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to UTF8 encoding. +AUTOREPLYPRINT_API int CP_Page_DrawTextInUTF8(void *handle, int x, int y, const wchar_t *str); + + // draw text in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to GBK encoding. +AUTOREPLYPRINT_API int CP_Page_DrawTextInGBK(void *handle, int x, int y, const wchar_t *str); + + // draw text in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to BIG5 encoding. +AUTOREPLYPRINT_API int CP_Page_DrawTextInBIG5(void *handle, int x, int y, const wchar_t *str); + + // draw text in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to ShiftJIS encoding. +AUTOREPLYPRINT_API int CP_Page_DrawTextInShiftJIS(void *handle, int x, int y, const wchar_t *str); + + // draw text in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to EUCKR encoding. +AUTOREPLYPRINT_API int CP_Page_DrawTextInEUCKR(void *handle, int x, int y, const wchar_t *str); + + // print 1D barcode in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // nBarcodeType + // barcode type + // values are defined as follow: + // value type + // 0x41 UPC-A + // 0x42 UPC-E + // 0x43 EAN13 + // 0x44 EAN8 + // 0x45 CODE39 + // 0x46 ITF + // 0x47 CODABAR + // 0x48 CODE93 + // 0x49 CODE128 + // + // str + // the barcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_DrawBarcode(void *handle, int x, int y, CP_Pos_BarcodeType nBarcodeType, const char *str); + + // print qrcode in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // nVersion + // Assign charater version. The value range is:[0,16] + // When version is 0, printer caculates version number according to character set automatically. + // + // nECCLevel + // Assign error correction level. + // The value range is: [1, 4]. + // Definitios are as below: + // ECC error correction level + // 1 L:7%, low error correction, much data. + // 2 M:15%, medium error correction + // 3 Q:optimize error correction + // 4 H:30%, the highest error correction, less data. + // + // str + // the qrcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_DrawQRCode(void *handle, int x, int y, int nVersion, CP_QRCodeECC nECCLevel, const char *str); + + // print image in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // dstw + // the width to print + // + // dsth + // the height to print + // + // pszFile + // image file path + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_DrawRasterImageFromFile(void *handle, int x, int y, int dstw, int dsth, const char *pszFile, CP_ImageBinarizationMethod binaryzation_method); + + // print image in pagemode(data can be readed from file) + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // dstw + // the width to print + // + // dsth + // the height to print + // + // data + // image data + // + // data_size + // image data size + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_DrawRasterImageFromData(void *handle, int x, int y, int dstw, int dsth, const unsigned char *data, unsigned int data_size, CP_ImageBinarizationMethod binaryzation_method); + + // print image pixels in pagemode + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // img_data + // image pixels data + // + // img_datalen + // image pixels data length + // + // img_width + // image pixel width + // + // img_height + // image pixel height + // + // img_stride + // image horizontal stirde. means bytes per line. + // + // img_format + // image pixel data format, values are defined as follow + // value define + // 1 mono + // 2 monolsb + // 3 gray + // 4 r.g.b in byte-ordered + // 5 b.g.r in byte-ordered + // 6 a.r.g.b in byte-ordered + // 7 r.g.b.a in byte-ordered + // 8 a.b.g.r in byte-ordered + // 9 b.g.r.a in byte-ordered + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Page_DrawRasterImageFromPixels(void *handle, int x, int y, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, CP_ImagePixelsFormat img_format, CP_ImageBinarizationMethod binaryzation_method); + + // enable black mark mode, need reboot printer. + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_BlackMark_EnableBlackMarkMode(void *handle); + + // disable black mark mode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_BlackMark_DisableBlackMarkMode(void *handle); + + // set black mark max search length(reboot will also valid) + // + // handle + // Port handle, returned by OpenXXX + // + // maxFindLength + // max find length (maxFindLength x 0.125 mm) + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_BlackMark_SetBlackMarkMaxFindLength(void *handle, int maxFindLength); + + // find next black mark + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_BlackMark_FindNextBlackMark(void *handle); + + // in black mode, set start print position + // + // handle + // Port handle, returned by OpenXXX + // + // position + // position > 0 means feed, position < 0 means feedback. distance is position x 0.125 mm. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_BlackMark_SetBlackMarkPaperPrintPosition(void *handle, int position); + + // in black mark mode, set cut position + // + // handle + // Port handle, returned by OpenXXX + // + // position + // position > 0 means feed, position < 0 means feedback. distance is position x 0.125 mm. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_BlackMark_SetBlackMarkPaperCutPosition(void *handle, int position); + + // full cut paper + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_BlackMark_FullCutBlackMarkPaper(void *handle); + + // half cut paper + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_BlackMark_HalfCutBlackMarkPaper(void *handle); + + // enable label mode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_EnableLabelMode(void *handle); + + // disable label mode + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DisableLabelMode(void *handle); + + // calibrate label paper(change to different label paper, need calibration) + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_CalibrateLabel(void *handle); + + // Feed paper to gap + // + // handle + // Port handle, returned by OpenXXX + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_FeedLabel(void *handle); + + // assign the start of a label page, and set Page size, reference point coordinates and page rotation. + // + // handle + // Port handle, returned by OpenXXX + // + // x + // page start point x coordinates + // + // y + // page start point y coordinates + // + // width + // page width + // + // height + // page height + // + // rotation + // page rotating. The value range of rotate is {0,1}. Page doesn't rotate to print as 0, and rotate 90 degree to print as 1. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_PageBegin(void *handle, int x, int y, int width, int height, CP_Label_Rotation rotation); + + // print the label page contents to label paper + // + // handle + // Port handle, returned by OpenXXX + // + // copies + // Copies [ 1 - 255 ] + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_PagePrint(void *handle, int copies); + + // draw text in assigned position of label page.only for single line + // + // handle + // Port handle, returned by OpenXXX + // + // x + // define text start position x coordinates,the value range is: [0,Page_Width-1] + // + // y + // define text start position y coordinates,the value range is: [0,Page_Height-1] + // + // font + // Choose font, can use 24. + // some printer can use 16, [20,99]. + // + // style + // chracter style. + // Databits define + // 0 Bold flag bit: font bold for 1,don't bold if reset zero clearing. + // 1 underline flag bit: underline text for 1, don't underline if rest zero clearing + // 2 inverse flag bit: inverse for 1(white in black), don't inverse rest zero clearing + // 3 delete line flage bit: for 1 text with delete line,don't delete line if reset zero clearing. + // [5,4] rotate flag bit: 00 rotates 0 degree + // 01 rotates 90 degree + // 10 rotates 180 degree + // 11 rotates 270 degree + // [11,8] font width magnification times; + // [15,12] font height magnification times; + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawText(void *handle, int x, int y, int font, int style, const char *str); + + // draw text in assigned position of label page.only for single line + // + // handle + // Port handle, returned by OpenXXX + // + // x + // define text start position x coordinates,the value range is: [0,Page_Width-1] + // + // y + // define text start position y coordinates,the value range is: [0,Page_Height-1] + // + // font + // Choose font, can use 24. + // some printer can use 16, [20,99]. + // + // style + // chracter style. + // Databits define + // 0 Bold flag bit: font bold for 1,don't bold if reset zero clearing. + // 1 underline flag bit: underline text for 1, don't underline if rest zero clearing + // 2 inverse flag bit: inverse for 1(white in black), don't inverse rest zero clearing + // 3 delete line flage bit: for 1 text with delete line,don't delete line if reset zero clearing. + // [5,4] rotate flag bit: 00 rotates 0 degree + // 01 rotates 90 degree + // 10 rotates 180 degree + // 11 rotates 270 degree + // [11,8] font width magnification times; + // [15,12] font height magnification times; + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to UTF8 encoding. +AUTOREPLYPRINT_API int CP_Label_DrawTextInUTF8(void *handle, int x, int y, int font, int style, const wchar_t *str); + + // draw text in assigned position of label page.only for single line + // + // handle + // Port handle, returned by OpenXXX + // + // x + // define text start position x coordinates,the value range is: [0,Page_Width-1] + // + // y + // define text start position y coordinates,the value range is: [0,Page_Height-1] + // + // font + // Choose font, can use 24. + // some printer can use 16, [20,99]. + // + // style + // chracter style. + // Databits define + // 0 Bold flag bit: font bold for 1,don't bold if reset zero clearing. + // 1 underline flag bit: underline text for 1, don't underline if rest zero clearing + // 2 inverse flag bit: inverse for 1(white in black), don't inverse rest zero clearing + // 3 delete line flage bit: for 1 text with delete line,don't delete line if reset zero clearing. + // [5,4] rotate flag bit: 00 rotates 0 degree + // 01 rotates 90 degree + // 10 rotates 180 degree + // 11 rotates 270 degree + // [11,8] font width magnification times; + // [15,12] font height magnification times; + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to GBK encoding. +AUTOREPLYPRINT_API int CP_Label_DrawTextInGBK(void *handle, int x, int y, int font, int style, const wchar_t *str); + + // draw text in assigned position of label page.only for single line + // + // handle + // Port handle, returned by OpenXXX + // + // x + // define text start position x coordinates,the value range is: [0,Page_Width-1] + // + // y + // define text start position y coordinates,the value range is: [0,Page_Height-1] + // + // font + // Choose font, can use 24. + // some printer can use 16, [20,99]. + // + // style + // chracter style. + // Databits define + // 0 Bold flag bit: font bold for 1,don't bold if reset zero clearing. + // 1 underline flag bit: underline text for 1, don't underline if rest zero clearing + // 2 inverse flag bit: inverse for 1(white in black), don't inverse rest zero clearing + // 3 delete line flage bit: for 1 text with delete line,don't delete line if reset zero clearing. + // [5,4] rotate flag bit: 00 rotates 0 degree + // 01 rotates 90 degree + // 10 rotates 180 degree + // 11 rotates 270 degree + // [11,8] font width magnification times; + // [15,12] font height magnification times; + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to BIG5 encoding. +AUTOREPLYPRINT_API int CP_Label_DrawTextInBIG5(void *handle, int x, int y, int font, int style, const wchar_t *str); + + // draw text in assigned position of label page.only for single line + // + // handle + // Port handle, returned by OpenXXX + // + // x + // define text start position x coordinates,the value range is: [0,Page_Width-1] + // + // y + // define text start position y coordinates,the value range is: [0,Page_Height-1] + // + // font + // Choose font, can use 24. + // some printer can use 16, [20,99]. + // + // style + // chracter style. + // Databits define + // 0 Bold flag bit: font bold for 1,don't bold if reset zero clearing. + // 1 underline flag bit: underline text for 1, don't underline if rest zero clearing + // 2 inverse flag bit: inverse for 1(white in black), don't inverse rest zero clearing + // 3 delete line flage bit: for 1 text with delete line,don't delete line if reset zero clearing. + // [5,4] rotate flag bit: 00 rotates 0 degree + // 01 rotates 90 degree + // 10 rotates 180 degree + // 11 rotates 270 degree + // [11,8] font width magnification times; + // [15,12] font height magnification times; + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to ShiftJIS encoding. +AUTOREPLYPRINT_API int CP_Label_DrawTextInShiftJIS(void *handle, int x, int y, int font, int style, const wchar_t *str); + + // draw text in assigned position of label page.only for single line + // + // handle + // Port handle, returned by OpenXXX + // + // x + // define text start position x coordinates,the value range is: [0,Page_Width-1] + // + // y + // define text start position y coordinates,the value range is: [0,Page_Height-1] + // + // font + // Choose font, can use 24. + // some printer can use 16, [20,99]. + // + // style + // chracter style. + // Databits define + // 0 Bold flag bit: font bold for 1,don't bold if reset zero clearing. + // 1 underline flag bit: underline text for 1, don't underline if rest zero clearing + // 2 inverse flag bit: inverse for 1(white in black), don't inverse rest zero clearing + // 3 delete line flage bit: for 1 text with delete line,don't delete line if reset zero clearing. + // [5,4] rotate flag bit: 00 rotates 0 degree + // 01 rotates 90 degree + // 10 rotates 180 degree + // 11 rotates 270 degree + // [11,8] font width magnification times; + // [15,12] font height magnification times; + // + // str + // the string to print + // + // return + // If command is written successfully, it returns true else it returns false. + // + // remarks + // The function converts the data to EUCKR encoding. +AUTOREPLYPRINT_API int CP_Label_DrawTextInEUCKR(void *handle, int x, int y, int font, int style, const wchar_t *str); + + // draw text in assigned position of label page.only for single line + // + // handle + // Port handle, returned by OpenXXX + // + // x + // define text start position x coordinates,the value range is: [0,Page_Width-1] + // + // y + // define text start position y coordinates,the value range is: [0,Page_Height-1] + // + // font + // Choose font, can use 24. + // some printer can use 16, [20,99]. + // + // style + // chracter style. + // Databits define + // 0 Bold flag bit: font bold for 1,don't bold if reset zero clearing. + // 1 underline flag bit: underline text for 1, don't underline if rest zero clearing + // 2 inverse flag bit: inverse for 1(white in black), don't inverse rest zero clearing + // 3 delete line flage bit: for 1 text with delete line,don't delete line if reset zero clearing. + // [5,4] rotate flag bit: 00 rotates 0 degree + // 01 rotates 90 degree + // 10 rotates 180 degree + // 11 rotates 270 degree + // [11,8] font width magnification times; + // [15,12] font height magnification times; + // + // str + // the string to print + // + // len + // the length to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawTextInBytes(void *handle, int x, int y, int font, int style, const char *str, int len); + + // Draw 1D code in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // barcode top left corner x coordinates, the value range is: [0,Page_Width-1] + // + // y + // barcode top left corner y coordinates, the value range is: [0,Page_Height-1] + // + // nBarcodeType + // barcode type + // values are defined as macros + // + // nBarcodeTextPrintPosition + // barcode readable text position, value range is [0, 3]. + // value defined as follow: + // value define + // 0 don't show readable text + // 1 show readable text below barcode + // 2 show readable text above barcode + // 3 show readable text above and below barcode + // + // height + // define barcode height + // + // unitwidth + // It assigns the basic element width. value range is [1, 4]. + // + // rotation + // Mean rotating angle, + // the value range is: [0, 3]. + // Definitions are as below: + // Rotate value define + // 0 doesn't rotate to draw + // 1 rotates 90 degree draw. + // 2 rotates 180 degree draw. + // 3 rotates 270 degree draw + // + // str + // the barcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawBarcode(void *handle, int x, int y, CP_Label_BarcodeType nBarcodeType, CP_Label_BarcodeTextPrintPosition nBarcodeTextPrintPosition, int height, int unitwidth, CP_Label_Rotation rotation, const char *str); + + // print qrcode in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // Top left corner x coordinates, the value range is: [0,Page_Width-1] + // + // y + // Top left corner y coordinates, the value range is: [0,Page_Height-1] + // + // nVersion + // Assign charater version. The value range is:[0,16] + // When version is 0, printer caculates version number according to character set automatically. + // + // nECCLevel + // Assign error correction level. + // The value range is: [1, 4]. + // Definitios are as below: + // ECC error correction level + // 1 L: 7%, low error correction, much data. + // 2 M: 15%, medium error correction + // 3 Q: optimize error correction + // 4 H: 30%, the highest error correction, less data. + // + // unitwidth + // It assigns the basic element width. value range is [1, 4]. + // + // rotation + // Mean rotating angle, + // the value range is: [0, 3]. + // Definitions are as below: + // Rotate value define + // 0 doesn't rotate to draw + // 1 rotates 90 degree draw. + // 2 rotates 180 degree draw. + // 3 rotates 270 degree draw + // + // str + // the qrcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawQRCode(void *handle, int x, int y, int nVersion, CP_QRCodeECC nECCLevel, int unitwidth, CP_Label_Rotation rotation, const char *str); + + // print qrcode in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // Top left corner x coordinates, the value range is: [0,Page_Width-1] + // + // y + // Top left corner y coordinates, the value range is: [0,Page_Height-1] + // + // nVersion + // Assign charater version. The value range is:[0,16] + // When version is 0, printer caculates version number according to character set automatically. + // + // nECCLevel + // Assign error correction level. + // The value range is: [1, 4]. + // Definitios are as below: + // ECC error correction level + // 1 L: 7%, low error correction, much data. + // 2 M: 15%, medium error correction + // 3 Q: optimize error correction + // 4 H: 30%, the highest error correction, less data. + // + // unitwidth + // It assigns the basic element width. value range is [1, 4]. + // + // rotation + // Mean rotating angle, + // the value range is: [0, 3]. + // Definitions are as below: + // Rotate value define + // 0 doesn't rotate to draw + // 1 rotates 90 degree draw. + // 2 rotates 180 degree draw. + // 3 rotates 270 degree draw + // + // str + // the qrcode data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawQRCodeInUTF8(void *handle, int x, int y, int nVersion, CP_QRCodeECC nECCLevel, int unitwidth, CP_Label_Rotation rotation, const wchar_t *str); + + // print qrcode in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // Top left corner x coordinates, the value range is: [0,Page_Width-1] + // + // y + // Top left corner y coordinates, the value range is: [0,Page_Height-1] + // + // nVersion + // Assign charater version. The value range is:[0,16] + // When version is 0, printer caculates version number according to character set automatically. + // + // nECCLevel + // Assign error correction level. + // The value range is: [1, 4]. + // Definitios are as below: + // ECC error correction level + // 1 L: 7%, low error correction, much data. + // 2 M: 15%, medium error correction + // 3 Q: optimize error correction + // 4 H: 30%, the highest error correction, less data. + // + // unitwidth + // It assigns the basic element width. value range is [1, 4]. + // + // rotation + // Mean rotating angle, + // the value range is: [0, 3]. + // Definitions are as below: + // Rotate value define + // 0 doesn't rotate to draw + // 1 rotates 90 degree draw. + // 2 rotates 180 degree draw. + // 3 rotates 270 degree draw + // + // str + // the qrcode data to print + // + // len + // the length to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawQRCodeInBytes(void *handle, int x, int y, int nVersion, CP_QRCodeECC nECCLevel, int unitwidth, CP_Label_Rotation rotation, const char *str, int len); + + // print pdf417code in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // Top left corner x coordinates, the value range is: [0,Page_Width-1] + // + // y + // Top left corner y coordinates, the value range is: [0,Page_Height-1] + // + // column + // ColNum is colnum, which means how many digits in per line. A digit is 17*UnitWidth dots. Line number is produces automatically by printer,the limited range is 3~90. ColNum value range:[1,30]. + // + // nECCLevel + // Assign error correction level. + // The value range is: [0, 8]. + // Ecc value, error correction number, stored files number(byte) + // 0 2 1108 + // 1 4 1106 + // 2 8 1101 + // 3 16 1092 + // 4 32 1072 + // 5 64 1024 + // 6 128 957 + // 7 256 804 + // 8 512 496 + // + // unitwidth + // It assigns the basic element width. value range is [1, 3]. + // + // rotation + // Mean rotating angle, + // the value range is: [0, 3]. + // Definitions are as below: + // Rotate value define + // 0 doesn't rotate to draw + // 1 rotates 90 degree draw. + // 2 rotates 180 degree draw. + // 3 rotates 270 degree draw + // + // str + // the pdf417 data to print + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawPDF417Code(void *handle, int x, int y, int column, int nAspectRatio, int nECCLevel, int unitwidth, CP_Label_Rotation rotation, const char *str); + + // Draw picture in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // Top left corner x coordinates, the value range is: [0,Page_Width-1] + // + // y + // Top left corner y coordinates, the value range is: [0,Page_Height-1] + // + // dstw + // the width to print + // + // dsth + // the height to print + // + // pszFile + // image file path + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // compression_method + // print data compress method, values are defined as follow + // value define + // 0 no compress + // 1 compress level 1 + // 2 compress level 2 + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawImageFromFile(void *handle, int x, int y, int dstw, int dsth, const char *pszFile, CP_ImageBinarizationMethod binaryzation_method, CP_ImageCompressionMethod compression_method); + + // Draw picture in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // Top left corner x coordinates, the value range is: [0,Page_Width-1] + // + // y + // Top left corner y coordinates, the value range is: [0,Page_Height-1] + // + // dstw + // the width to print + // + // dsth + // the height to print + // + // data + // image data + // + // data_size + // image data size + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // compression_method + // print data compress method, values are defined as follow + // value define + // 0 no compress + // 1 compress level 1 + // 2 compress level 2 + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawImageFromData(void *handle, int x, int y, int dstw, int dsth, const unsigned char *data, unsigned int data_size, CP_ImageBinarizationMethod binaryzation_method, CP_ImageCompressionMethod compression_method); + + // Draw picture in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // Top left corner x coordinates, the value range is: [0,Page_Width-1] + // + // y + // Top left corner y coordinates, the value range is: [0,Page_Height-1] + // + // img_data + // image pixels data + // + // img_datalen + // image pixels data length + // + // img_width + // image pixel width + // + // img_height + // image pixel height + // + // img_stride + // image horizontal stirde. means bytes per line. + // + // img_format + // image pixel data format, values are defined as follow + // value define + // 1 mono + // 2 monolsb + // 3 gray + // 4 r.g.b in byte-ordered + // 5 b.g.r in byte-ordered + // 6 a.r.g.b in byte-ordered + // 7 r.g.b.a in byte-ordered + // 8 a.b.g.r in byte-ordered + // 9 b.g.r.a in byte-ordered + // + // binaryzation_method + // image binaryzation method. 0 means use dithering, 1 means use thresholding, 2 means use error diffusion. + // + // compression_method + // print data compress method, values are defined as follow + // value define + // 0 no compress + // 1 compress level 1 + // 2 compress level 2 + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawImageFromPixels(void *handle, int x, int y, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, CP_ImagePixelsFormat img_format, CP_ImageBinarizationMethod binaryzation_method, CP_ImageCompressionMethod compression_method); + + // draw line in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // startx + // straightway start point x coordinates,the value range is: [0,Page_Width-1] + // + // starty + // straightway start point y coordinates,the value range is: [0,Page_Height-1] + // + // endx + // straightway end point x coordinates,the value range is: [0,Page_Width-1] + // + // endy + // straightway end point y coordinates,the value range is:[0,Page_Height-1] + // + // linewidth + // line width + // + // linecolor + // line color, 0 means white, 1 means black. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawLine(void *handle, int startx, int starty, int endx, int endy, int linewidth, CP_Label_Color linecolor); + + // draw rect in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // width + // rect width + // + // height + // rect height + // + // color + // rect color, 0 means white, 1 means black. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawRect(void *handle, int x, int y, int width, int height, CP_Label_Color color); + + // draw box in the assigned position of label page + // + // handle + // Port handle, returned by OpenXXX + // + // x + // horizontal position + // + // y + // vertical position + // + // width + // box width + // + // height + // box height + // + // borderwidth + // box border width + // + // bordercolor + // box border color, 0 means white, 1 means black. + // + // return + // If command is written successfully, it returns true else it returns false. +AUTOREPLYPRINT_API int CP_Label_DrawBox(void *handle, int x, int y, int width, int height, int borderwidth, CP_Label_Color bordercolor); + + // Query battery level + // Only some models with batteries support this command + // + // handle + // Port handle, returned by OpenXXX + // + // timeout + // timeout ms + // The wait time for query does not exceed this time + // + // return + // Returns the battery power, and a range of 0-100. returns -1 to indicate that the query failed. +AUTOREPLYPRINT_API int CP_Proto_QueryBatteryLevel(void *handle, unsigned int timeout); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/main/resources/win32-x86-64/autoreplyprint.lib b/src/main/resources/win32-x86-64/autoreplyprint.lib new file mode 100644 index 0000000..9b5e5b3 Binary files /dev/null and b/src/main/resources/win32-x86-64/autoreplyprint.lib differ diff --git a/src/main/resources/win32-x86-64/copydll.bat b/src/main/resources/win32-x86-64/copydll.bat new file mode 100644 index 0000000..50e0ea7 --- /dev/null +++ b/src/main/resources/win32-x86-64/copydll.bat @@ -0,0 +1,4 @@ +copy ..\..\build-autoreplyprint-QT5_6_0_VC2015_STATIC_64-Release\release\autoreplyprint.dll . /y +copy ..\..\build-autoreplyprint-QT5_6_0_VC2015_STATIC_64-Release\release\autoreplyprint.exp . /y +copy ..\..\build-autoreplyprint-QT5_6_0_VC2015_STATIC_64-Release\release\autoreplyprint.lib . /y +copy ..\..\..\autoreplyprint_src\autoreplyprint_main\autoreplyprint.h . /y diff --git a/src/test/java/com/dpkj/ems/EmsExpressBridgeApplicationTests.java b/src/test/java/com/dpkj/ems/EmsExpressBridgeApplicationTests.java deleted file mode 100644 index f8f9d75..0000000 --- a/src/test/java/com/dpkj/ems/EmsExpressBridgeApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dpkj.ems; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class EmsExpressBridgeApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/src/test/java/com/dpkj/ems/utils/PrinterUtilTest.java b/src/test/java/com/dpkj/ems/utils/PrinterUtilTest.java deleted file mode 100644 index ad6d250..0000000 --- a/src/test/java/com/dpkj/ems/utils/PrinterUtilTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.dpkj.ems.utils; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.lang.Console; -import com.dpkj.Application; -import com.dpkj.common.config.FileConfig; -import com.dpkj.modules.express.service.PrinterService; -import com.dpkj.modules.express.utils.FileUtils; -import com.dpkj.modules.express.utils.PrinterUtil; -import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.List; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class) -class PrinterUtilTest { - - @Autowired - private PrinterService printerService; - @Autowired - private FileConfig fileConfig; - - @Test - void getPrintSDK() throws PrinterUtil.PrinterRegistrationException { - PrinterUtil.MsPrintSdk sdk = PrinterUtil.getPrintSDK(); - int i = sdk.SetUsbportauto(); - Console.log(i); - - int i1 = sdk.SetInit(); - Console.log(i1); - - int i2 = sdk.GetStatusspecial(); - Console.log(i2); - } - - @Test - void t2() throws IOException { - String base64Path = "G:\\Temp\\text\\base64.txt"; - String base64 = FileUtil.readString(FileUtil.file(base64Path), StandardCharsets.UTF_8); - - String bpmPath = "G:\\Temp\\img"; - List bufferedImages = FileUtils.convertBase64PdfToBufferedImage(base64); - FileUtils.saveBufferedImageToBmp(bufferedImages); - } - - - @Test - void t3() throws Exception { - String base64Path = "G:\\Temp\\text\\base64.txt"; - String base64 = FileUtil.readString(FileUtil.file(base64Path), StandardCharsets.UTF_8); - - // String bpmPath = "G:\\Temp\\img"; - String bpmPath = fileConfig.getPath(); - List bufferedImages = FileUtils.convertBase64PdfToBufferedImage(base64); - List files = FileUtils.saveBufferedImageToBmp(bufferedImages); - - /*for (File file : files) { - String filePath = file.getAbsolutePath(); - printerService.printBmpByPath(filePath); - }*/ - } - - @Test - void t4() throws IOException { - String base64Path = "G:\\Temp\\text\\base64.txt"; - String base64 = FileUtil.readString(FileUtil.file(base64Path), StandardCharsets.UTF_8); - - List bufferedImages = FileUtils.convertBase64PdfToBufferedImage(base64); - System.out.println(bufferedImages); - } -} diff --git a/src/test/java/com/dpkj/ems/utils/PrinterUtilTest2.java b/src/test/java/com/dpkj/ems/utils/PrinterUtilTest2.java deleted file mode 100644 index 3f198fd..0000000 --- a/src/test/java/com/dpkj/ems/utils/PrinterUtilTest2.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.dpkj.ems.utils; - -import cn.hutool.core.io.FileUtil; -import com.dpkj.modules.express.utils.FileUtils; -import org.junit.jupiter.api.Test; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.List; - -class PrinterUtilTest2 { - - @Test - void t4() throws IOException { - String base64Path = "G:\\Temp\\text\\base64.txt"; - String base64 = FileUtil.readString(FileUtil.file(base64Path), StandardCharsets.UTF_8); - - List bufferedImages = FileUtils.convertBase64PdfToBufferedImage(base64); - System.out.println(bufferedImages); - } -}