在android中的Star TSP100打印机上创建光栅收据

在android中的Star TSP100打印机上创建光栅收据,android,printing,receipt,javapos,stario-sdk,Android,Printing,Receipt,Javapos,Stario Sdk,我正在尝试创建一个收据,将从android设备打印到TSP100星形打印机。我到处搜索,找不到打印光栅化收据的简单示例(因为TSP100只接受光栅)。我给Star发了电子邮件,他们给我发了以下代码,但我不确定这是否正确,也不确定如何将其转换为格式化位图并打印出来 byte[] data; ArrayList<Byte> list = new ArrayList<Byte>(); Byte[] tempList; list.addAll(A

我正在尝试创建一个收据,将从android设备打印到TSP100星形打印机。我到处搜索,找不到打印光栅化收据的简单示例(因为TSP100只接受光栅)。我给Star发了电子邮件,他们给我发了以下代码,但我不确定这是否正确,也不确定如何将其转换为格式化位图并打印出来

    byte[] data;
    ArrayList<Byte> list = new ArrayList<Byte>();

    Byte[] tempList;
    list.addAll(Arrays.asList(new Byte[]{0x1b, 0x1d, 0x61, 0x01}));

    data = "[If loaded.. Logo1 goes here]\r\n".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));

    list.addAll(Arrays.asList(new Byte[]{0x1b, 0x1c, 0x70, 0x01, 0x00, '\r', '\n'}));  //Stored Logo Printing

    data = "Company Name\r\n".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));

    data = "Street1\r\nCity, ST, ZIPCODE\r\n\r\n".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));

    list.addAll(Arrays.asList(new Byte[]{0x1b, 0x1d, 0x61, 0x00})); // Alignment

    list.addAll(Arrays.asList(new Byte[]{0x1b, 0x44, 0x02, 0x10, 0x22, 0x00})); //Set horizontal tab

    data = "Date: 2/22/2012".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));

    list.addAll(Arrays.asList(new Byte[]{' ', 0x09, ' '}));   //Moving Horizontal Tab

    data = "Time: 9:18 PM\r\n------------------------------------------------\r\n\r\n".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));

    list.addAll(Arrays.asList(new Byte[]{0x1b, 0x45})); // bold

    data = "SALE \r\n".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));

    list.addAll(Arrays.asList(new Byte[]{0x1b, 0x46})); // bolf off

    data = "SKU ".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));

    list.addAll(Arrays.asList(new Byte[]{0x09}));

    // notice that we use a unicode representation because that is how Java expresses these bytes at double byte unicode
    // This will TAB to the next horizontal position
    data = " Description   \u0009         Total\r\n".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));
data = "34353434 \u0009  SP500\u0009        100.99\r\n".getBytes();
    tempList = new Byte[data.length];
    CopyArray(data, tempList);
    list.addAll(Arrays.asList(tempList));
byte[]数据;
ArrayList=新建ArrayList();
字节[]模板;
addAll(Arrays.asList(新字节[]{0x1b,0x1d,0x61,0x01}));
data=“[If loaded..Logo1在这里]\r\n.getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
addAll(Arrays.asList(新字节[]{0x1b,0x1c,0x70,0x01,0x00,'\r','\n'}))//存储标识打印
data=“公司名称\r\n”。getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
data=“Street1\r\nCity,ST,ZIPCODE\r\n\r\n”.getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
addAll(Arrays.asList(新字节[]{0x1b,0x1d,0x61,0x00}));//对齐
addAll(Arrays.asList(新字节[]{0x1b,0x44,0x02,0x10,0x22,0x00}))//设置水平选项卡
data=“日期:2012年2月22日”。getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
addAll(Arrays.asList(新字节[]{'',0x09',}))//移动水平选项卡
data=“时间:晚上9:18\r\n--------------------------------------------\r\n\r\n”。getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
addAll(Arrays.asList(新字节[]{0x1b,0x45}));//大胆的
data=“SALE\r\n”。getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
addAll(Arrays.asList(新字节[]{0x1b,0x46}));//大发雷霆
data=“SKU”。getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
addAll(Arrays.asList(新字节[]{0x09}));
//请注意,我们使用unicode表示,因为Java就是用双字节unicode表示这些字节的
//这将使制表符移动到下一个水平位置
data=“Description\u0009 Total\r\n”.getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
data=“34353434\u0009 SP500\u0009 100.99\r\n”.getBytes();
tempList=新字节[data.length];
CopyArray(数据、模板);
addAll(Arrays.asList(templast));
等等

现在,从ArrayList列表到打印机的位图。一个简单的收据例子会有帮助。我已经向STAR索取了,但不确定他们需要多长时间才能回来。我想一定是有人干的


谢谢。

你从哪里得到的代码?这实际上是我不久前创建的收据的一小部分。我是Kale Evans,在Star Micronics工作


此示例演示如何将数据作为原始文本发送到打印机。如果您希望将光栅数据发送到打印机,则必须将收据呈现为android位图,然后将其作为参数传递给我相信的PrintImageAsBitmap函数(或类似名称。请查看光栅解释活动)。

您从何处获得该代码?这实际上是我不久前创建的收据的一小部分。我是Kale Evans,在Star Micronics工作


此示例演示如何将数据作为原始文本发送到打印机。如果您希望将光栅数据发送到打印机,则必须将收据呈现为android位图,然后将其作为参数传递到我相信的PrintImageAsBitmap函数中(或类似名称。请查看光栅解释活动)。

嗨,Kale Evans,我想知道ODP 160-G是否支持通过USB进行移动打印?嗨,Kale,我想知道android如何通过USB检测打印机星TSP100 eco,我已经根据手册进行了尝试,但没有得到它检测到打印机,我已经在平板电脑(nexus 7和kindle fire)hi Kale Evans上安装了SDK应用程序。如何在线打印徽标和重启名称?提前感谢hi Kale Evans,我想知道ODP160-G是否支持通过USB进行移动打印?嗨,Kale,我想知道我能为android通过USB检测打印机星TSP100 eco做些什么,我已经根据手册进行了尝试,但没有得到它检测打印机,我已经在平板电脑上安装了SDK应用程序(nexus 7和kindle fire)嗨,Kale Evans。如何在线打印徽标和餐厅名称?提前谢谢