我正在编写密码呼叫系统,但无法打印呼号。基本上它应该打印一个像“C1234”这样的字符串,但它只打印没有以下数字的“C”。
已经尝试弄乱 DocFlavor 和 InputStream 类型,但是每次打印时问题都会重复。
这是打印功能。
public void PrintSenha()
{
String impressora = PrintServiceLookup.lookupDefaultPrintService().getName();
System.out.println("Default Printer: "+impressora);
PrintService servico = PrintServiceLookup.lookupDefaultPrintService();
String senha = "C2450";
byte[] dados;
try {
dados = senha.getBytes();
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(new Copies(1));
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new SimpleDoc(dados, flavor, null);
DocPrintJob job = servico.createPrintJob();
job.print(doc, pras);
} catch (PrintException ex) {
Logger.getLogger(Operacoes.class.getName()).log(Level.SEVERE, null, ex);
System.err.print("Print Exception"+ex.getMessage());
}
}