adasi Posted August 9, 2011 Share Posted August 9, 2011 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 More sharing options...
szaharia Posted August 9, 2011 Share Posted August 9, 2011 Hi,Take a look at the printservice sample in the JR samples directory.Hope this helps,sanda Link to comment Share on other sites More sharing options...
paulo.alexandre88 Posted October 16, 2013 Share Posted October 16, 2013 The page you requested does not exist. Link to comment Share on other sites More sharing options...
szaharia Posted October 17, 2013 Share Posted October 17, 2013 Hi, the requested page was available in 2011, when the question was asked. Now it is relocated here: http://jasperreports.sourceforge.net/sample.reference/printservice/index.html#printservice Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now