Jump to content

Can we direct print the jasper report without viewing the report?


adasi

Recommended Posts

Hey....

In the java program.....

After putting the relevent parameteres  and then press the print button...the report will print..

That mean  the report will not view and  will not open print dialog...

is the there a cording ???

 

can you help me please!!

i put some code below...can u tell me that code is correct or not  or we can do our work from that code....

can u put the corrected code please!!!!!!!!

 

 

Code:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package Classes;import java.util.Map;import javax.print.PrintService;import javax.print.PrintServiceLookup;import javax.print.attribute.HashPrintRequestAttributeSet;import javax.print.attribute.PrintRequestAttributeSet;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRExporter;import net.sf.jasperreports.engine.JRExporterParameter;import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.JasperReport;import net.sf.jasperreports.engine.export.JRPrintServiceExporter;import net.sf.jasperreports.engine.export.JRPrintServiceExporterParameter;/** * * @author Admin */public class cls_Report_passBook {    String reportDir = "D:\\easyBanker\\src\\Report\\";    String reportDir2 = "H:/PrintCheck";    public  void generateReport(String reportname, Map params) throws JRException{                        String printer="CutePDF Writer";                        PrintService service = null;                        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();                     //   aset.add(MediaSizeName.ISO_A4);                        PrintService[] services3 = PrintServiceLookup.lookupPrintServices(null, null);                        for(int k=0;k<services3.length;k++){                        if(services3[k].getName().trim().equals(printer.trim())){                        service = services3[k];                        }                        }                        //System.out.println("AAAAAAAAA"+service);                        if(service == null){                         System.out.println("PRINTER NOT FOUND->"+printer);                        }else {            System.out.println("AAAAAAAAA");            JasperReport jr = JasperCompileManager.compileReport(reportDir + reportname);            JasperPrint jp = JasperFillManager.fillReport(jr, params, new cls_Connect().connect());            JRExporter exporter = new JRPrintServiceExporter();            exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);            exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, service.getAttributes());            exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, service.getAttributes());            exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);            exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);            exporter.exportReport();                        }         }}
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...