2016-07-29 2 views
0

私のプリンタジョブに問題があります。 私のスクリプトを設定して用紙サイズを設定しましたが、プリンタは印刷終了後に常にスクロールします。 私はepson LX私のepson LX-300、LX-310、およびLX-800では、正常に動作し、プリンタの自動停止が完了しましたが、epson LX-300 + IIでは、プリンタは印刷終了後に常にスクロールします。 私はなぜ知らない、と私は印刷のために同じスクリプトを使用.. ここでは、設定されたカスタム用紙サイズのための私のスクリプトです:プリンタジョブで完了した後に印刷を停止する方法

public void setPrinter(String textParam, String spesialWords, int gotoX2) { 

    try { 
     String destination = ""; 
     boolean printToDoc = true; 
     PrinterJob pj = PrinterJob.getPrinterJob(); 
     //boolean printDialog = pj.printDialog(); 
     System.out.println("--------------------"); 

     //PageFormat pf = pj.getPageFormat(null); 
     PageFormat pf = pj.defaultPage(); 
     Paper paper = pf.getPaper(); 

     double cm = 72.0/2.54; 
     if (!destination.equalsIgnoreCase("document.pdf")) { 
      if (destination.equalsIgnoreCase("printer")) { 
       paper.setSize(26 * cm, 7 * cm); 
      } 
     } 
       paper.setSize(23 * cm, 7 * cm); 
     double getHeight = 7 * cm; 
     double getWidth = 23 * cm; 
     double margin = 0.0; // half inch 

     paper.setImageableArea(margin, margin, paper.getWidth(), paper.getHeight()); 
     pf.setPaper(paper); 
     System.out.println("=========================================="); 
     System.out.println("paper height : "+getHeight); 
     System.out.println("paper width : "+getWidth); 

     PrintRequestAttributeSet attr_set = new HashPrintRequestAttributeSet(); 
     if (destination.equalsIgnoreCase("document.pdf")) { 
      PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService(); 
      DocPrintJob printerJob = defaultPrintService.createPrintJob(); 
      File pdfFile = new File(destination); 
      SimpleDoc simpleDoc = new SimpleDoc(pdfFile.toURL(), DocFlavor.URL.AUTOSENSE, null); 
      try { 
       printerJob.print(simpleDoc, null); 
      } catch (PrintException ex) { 
       Logger.getLogger(Printing2.class.getName()).log(Level.SEVERE, null, ex); 
      } 

     } else if (destination.equalsIgnoreCase("document.ps")) { 
      try { 
       if (textParam.toLowerCase().contains("post")) { 
        destination = "post_"+destination; 
       } else if (textParam.toLowerCase().contains("non")) { 
        destination = "non_"+destination; 
       } else if (textParam.toLowerCase().contains("token")) { 
        destination = "pre_"+destination; 
       } 

       attr_set.add(new Destination(new java.net.URI("file:" + destination))); 
      } catch (URISyntaxException ex) { 
       Logger.getLogger(Printing2.class.getName()).log(Level.SEVERE, null, ex); 
      } 
     } 
     PrinterResolution pr = new PrinterResolution(120, 144, PrinterResolution.DPI); 
     attr_set.add(pr); 

     pj.setPrintable(new MyPrintable(textParam, spesialWords, gotoX2), pf); 
     if (!destination.equalsIgnoreCase("document.pdf")) { 

      try { 
       //System.out.println("ini print"); 
       if (destination.equalsIgnoreCase("xps")) { 
        pj.print(); 
       } else { 
        pj.print(attr_set); 
       } 
      } catch (PrinterException e) { 
       System.out.println(e); 
       javax.swing.JOptionPane.showMessageDialog(rootPane, "Gagal mencetak struk, Silahkan lihat pengaturan printer anda"); 
      } 
     } 

    } catch (IOException ex) { 
     //System.out.println("testing cuuy"); 
     Logger.getLogger(Printing2.class.getName()).log(Level.SEVERE, null, ex); 
    } 

} 

答えて

0

私は私の問題を解決する:lx-の私のドライバプリンタを変更 300 + II to lx-800 なぜか分かりません。 でも完全に動作しています

関連する問題