【问题标题】:Creating a raster receipt on Star TSP100 printer in android在 android 的 Star TSP100 打印机上创建光栅收据
【发布时间】:2012-05-05 14:31:07
【问题描述】:

我正在尝试创建可以从 Android 设备打印到 TSP100 Star 打印机的收据。我到处搜索,找不到打印光栅化收据的简单示例(因为 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));

ETC..

现在从 ArrayList 列表中获取到打印机的位图。一个简单的收据示例将有助于创造奇迹。我已经向 STAR 提出了要求,但不确定他们需要多长时间才能回来。我想肯定有人这样做了。

谢谢。

【问题讨论】:

    标签: android printing receipt javapos stario-sdk


    【解决方案1】:

    您从哪里获得该代码?这实际上是我不久前创建的收据的一个小sn-p。我是 Kale Evans,在 Star Micronics 工作。

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

    【讨论】:

    • 嗨 Kale Evans,我想知道 ODP 160-G 是否支持通过 USB 进行移动打印?
    • 嗨 Kale,我想知道我可以为 android 做些什么通过 USB 检测到打印机 Star TSP100 eco,我已经按照手册进行了尝试,但没有得到它检测到打印机,我已经安装了 SDK 应用程序在平板电脑上(nexus 7 和 kindle fire)starmicronics.com/Printer/…
    • 嗨 Kale Evans。如何在行中打印徽标和餐厅名称?提前致谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-28
    • 2016-09-23
    • 2013-07-17
    • 2021-10-07
    • 2018-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多