我这里有个程序是要把一个字符串打印出来,但是在打印的时候当字符串是字母开始后面接着数字(例:ZH0707081122),并且超过9位的时候程序没有出错但是打印机会报不支持你的打印格式的错误,但是如果把数字放在前面字母放在后面,或者小于9位就没有出错打印出来的。当然纯字符纯数字也没有出错。代码如下:
lotid = "CSJMAT001111";
byte[] bais = lotid1.getBytes();
DocFlavor psInFormat = DocFlavor.BYTE_ARRAY.AUTOSENSE;
SimpleDoc myDoc = new SimpleDoc(bais, psInFormat, null); 
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob job = service.createPrintJob();
try {
job.print(myDoc, aset);
    }catch (Exception e) {
      throw e;
    }
另外,我看了一下我这里的打印机只支持BYTE_ARRAY和INPUT_STREAM这两种DocFlavor
INPUT_STREAM我用了ByteArrayInputStream也不行。希望个位大虾指点一下错误或者有没有其他的解决方法。

解决方案 »

  1.   

    打印机报错? 打印驱动报错?  SimpleDoc的问题吧
      

  2.   

    就是程序没有出错,打印机的任务图标已经出来的,然后出了个错误
    The following erroe occurred during job submission:
    5010-606 The value hpgl that was specified or defaulted for attribute document-format is not supported by the destination or by any of its associated actual destinations.如果是SimpleDoc的问题的话应该用什么来实现呢?