过节前后都在忙这个打印程序。
现在换了方法能完全打印了,但是打印出来的空白边距很大不知道像我下面的情况有什么可以设置边距的不?
部分代码如下:   
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    pras.add(javax.print.attribute.standard.OrientationRequested.LANDSCAPE);  //横向打印
 
            DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;   
            PrintService printServi[] = 
              PrintServiceLookup.lookupPrintServices(flavor, pras);
           
            PrintService defaultService = 
              PrintServiceLookup.lookupDefaultPrintService();
            
            PrintService service = ServiceUI.printDialog(null, 50, 50,
              printServi, defaultService, flavor, pras);   
           
          try{
   ByteArrayOutputStream output = new ByteArrayOutputStream();
   ImageIO.write(image, "jpg", output);//image为BufferImage
   byte[] buff = output.toByteArray();
   InputStream iss= new ByteArrayInputStream(buff);
  
               DocPrintJob job = service.createPrintJob();
               DocAttributeSet das = new HashDocAttributeSet();
               Doc doc = new SimpleDoc(iss, flavor, das);
           
          /* PageFormat   pageFormat =  new PageFormat();//打印设置  
           Paper   paper=pageFormat.getPaper();            
           final   double   MM_TO_PAPER=1.0/25.4*72;//打印的尺寸单位,1/72英寸,转换成mm,要好用些  
           double   widthA4=210*MM_TO_PAPER;//用A4的纸,  
           double   heightA4=297*MM_TO_PAPER;  
           double   marginSize1=15*MM_TO_PAPER;//边距  
           double   marginSize2=10*MM_TO_PAPER;  
           paper.setSize(widthA4,heightA4);  
           paper.setImageableArea(marginSize2,marginSize1,widthA4-2*marginSize2,heightA4-2*marginSize1);  
           pageFormat.setPaper(paper);  
         //这些用不了。。
       */
          
              job.print(doc, pras);
              
          }
          catch(PrintException pe){
              pe.printStackTrace();
          }
          catch (IOException ioe){
         //  JOptionPane.showMessageDialog(this, ioe);
        }