2017-04-02 4 views
0

ジャスパーレポート(請求書)ファイルを作成し、JButtonで実行しました。ボタンをクリックすると、予期したとおりにプレビューが表示されますが、Jasper Viewerの印刷ボタンをクリックしてドットマトリックスプリンタ(TVS 240スター)で印刷すると、ページ上のフォント(ハードコピー)が重なり、サイズも変更されます。ジャスパーレポートフォントがドットマトリックスプリンタで印刷時に重複する

どうすればこの問題を解決できますか?

(ページサイズ5インチ幅6インチの高さ/ Arial Unicode MSフォント、9)

public void bill(){ 
    if(textField_10.getText().equals("")) 
      { 
     JOptionPane.showMessageDialog(null,"Enter Bill no. !","Invoice", getDefaultCloseOperation()); 
     textField_10.grabFocus(); 
    } 
    else{ 
    try{ 
     String para=textField_7.getText(); 
     String para1=textField_8.getText(); 
     String para2=textField_9.getText(); 
     String para3=textField_10.getText(); 
     String sourceName="/DBcon/new.jrxml"; 
     //String sourceName="/DBcon/Invoice.jrxml"; 
     java.io.InputStream in=null; 

    HashMap<String, Object> hm=new HashMap<String,Object>(); 
    hm.put("Retailer_Name",para); //jasper report parameter passing 
    hm.put("Address",para1); 
    hm.put("Contact",para2); 
    hm.put("Billno",para3); 

    in=getClass().getResourceAsStream(sourceName); 
    JasperReport jr=JasperCompileManager.compileReport(in); 
    JasperPrint jp=JasperFillManager.fillReport(jr,hm,con); 
    JasperViewer.viewReport(jp,false); 
    // JasperPrintManager.printReport(jp,true); 
    //JasperExportManager.exportReportToPdfFile(jp, destinationFile); 
    Exporter exp = new JRDocxExporter(); 
    exp.setExporterInput(new SimpleExporterInput(jp)); 
    File exportReportFile = new File("C:\\Users\\Public\\Documents\\invoice.docx"); 
    exp.setExporterOutput(new SimpleOutputStreamExporterOutput(exportReportFile)); 

    exp.exportReport();   
} 
    catch(Exception e){ 
     e.printStackTrace(); 
     JOptionPane.showMessageDialog(null,"Close previous invoice"); 
    } 
    } 
} 
+0

何かを開き、デフォルトのプリンタによってファイルを印刷しますあなたのデフォルトのPDFリーダー –

答えて

1

このエラーは、ほとんどのドットマトリックスプリンタで発生し、MSワードやPDFでレポートを印刷することにより、これを克服することができますリーダー。

JasperPrint jpd = JasperFillManager.fillReport(jrd, para, db.mycon()); 
File f = new File("C:\\PrintTemp\\"); //create a folder in c drive 
if (!f.exists()) { 
    f.mkdir(); 
} 
//delete previous files in the folder(this is not necessary) 
for (File file : f.listFiles()) { 
    if (!file.isDirectory()) { 
     file.delete(); 
    } 
} 

File destFile = new File(f + "print.pdf"); 
JasperExportManager.exportReportToPdfFile(jpd, destFile); 
//print the file 
Desktop desktop = Desktop.getDesktop(); 
if (desktop.isSupported(Desktop.Action.PRINT)) { 
    desktop.print(new File(destFile)); 
} 

* jrxmlの*(レポートのテンプレート)と間違って

関連する問題