简体   繁体   English

将视图转换为字节数组以进行打印

[英]Converting View to Byte Array to Print

I have a fragment that outputs plain text to the screen for viewing tickets. 我有一个片段,它将纯文本输出到屏幕以查看票证。 I am working on implementing a print function to print the content to a receipt printer (Star Micronics SM-T300i). 我正在实现打印功能,以将内容打印到收据打印机(Star Micronics SM-T300i)。 I have the SDK installed and working, but I'm just not connecting the dots on how to do this. 我已经安装了SDK,并且可以正常工作,但是我只是不了解如何执行此操作。 All the examples seem to be converting things into bitmaps from byte arrays, etc. This is my first printing app so I'm just not familiar with the process. 所有这些示例似乎都是将内容从字节数组等转换为位图。这是我的第一个打印应用程序,因此我只是不熟悉该过程。 I want to print the same XML file I use to view on the screen to the printer in text mode so it uses the printers native fonts. 我想以文本模式将用来在屏幕上查看的XML文件打印到打印机,以便它使用打印机的本机字体。 Am I on the wrong track? 我走错了路吗? Thank you. 谢谢。

I ended up using an ArrayList for each line item to print. 我最终对每个要打印的订单项使用ArrayList。 It is a receipt so there's no special formatted. 这是一张收据,所以没有特殊格式。 For example: 例如:

list.add(("Ticket NO: " + data.get("ticketNo") + "\n").getBytes());

I then sent the entire list to the printer SDK command to print. 然后,我将整个列表发送到打印机SDK命令进行打印。 Trying to print what the user sees on the screen was not necessary and easier to just output the information like this. 无需打印用户在屏幕上看到的内容,这样就更容易输出信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM