通常,当我将Zebra LP 2844-Z插入USB端口时,计算机将其视为打印机,我可以像其他任何通用打印机一样从记事本打印到它.但是,我的应用程序有一些条形码功能.我的应用程序解析一些输入并生成内存中的ZPL字符串.如何将此ZPL数据发送到USB设备?
我有一个文本文件,我需要将其打印到特定的网络打印机.我知道打印机的名称.
到目前为止,我已经制作了一个Printable类来打印我的文件(票证).
public class TicketPrintPage implements Printable {
private File ticket;
public TicketPrintPage(File f) {
ticket = f;
}
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
int interline = 12;
Graphics2D g2 = (Graphics2D) g;
g2.setFont(new Font("CourierThai", Font.PLAIN, 10));
int x = (int) pf.getImageableX();
int y = (int) pf.getImageableY();
try {
FileReader fr = new FileReader(ticket);
BufferedReader br = new BufferedReader(fr);
String s;
while ((s = br.readLine()) != null) {
y += interline;
g2.drawString(s, x, y); …Run Code Online (Sandbox Code Playgroud)