明星TSp654 POS打印机设置中的收据格式

时间:2012-04-12 08:47:32

标签: iphone thermal-printer

我已经与我的ipad建立了打印机连接,现在我想设置收据的格式,如对齐,水平标签,字体大小标识设置以及我收据中所需的所有东西,请任何人都可以帮我怎样才能使用在Objective-c中的POS命令呢?

谢谢

1 个答案:

答案 0 :(得分:1)

Star有一个编程手册,你可以在这里下载:http://www.starmicronics.com/support/Mannualfolder/linemode_cm_en.pdf

“线路模式”手册中引用的命令需要转换为字节,然后发送到打印机。您下载的StarIO iOS SDK软件包有一本名为“README_StarIO_POSPrinter_iOS_SDK.pdf”的手册。 (http://www.starmicronics.com/absolutefm/absolutefm/afmviewfaq.aspx?faqid=175)你看过第9-15页吗?这里解释了StarIO框架。

第13页介绍如何使用字节数组写入端口,但请确保添加StarIO.framework并首先打开通信端口。

从手册:

//Set a byte array to send to the printer
//command = { A, B, C, D, Feed 3mm, Full Cut}
unsigned char command = {0x41, 0x42, 0x43, 0x44, 0x1B, 0x7A, 0x00, 0x1B, 0x64, 0x02};

Uint bytesWritten = 0;

@Try
{ 
   While(bytesWritten < (sizeof command)) 
   {
    bytesWritten += [port writePort: command : bytesWritten : sizeof command - bytesWritten];
   }
}
@Catch(PortException)
{
   //There was an error writing to the port
}

还介绍了如何关闭端口(确保关闭每个打开的端口)并获取打印机状态。