alimahran666 Posted October 31, 2018 Share Posted October 31, 2018 when i use print button it,s show window print ,but i want to print report directally without show window . or how can add print button programatically to print directlly on JasperViewer windo ?i am used net.sf.jasperreports.view.JasperViewerbut iam don.t knowthanks u more Link to comment Share on other sites More sharing options...
reportdev Posted October 31, 2018 Share Posted October 31, 2018 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, con); //For Viewing the report JasperViewer.viewReport(jasperPrint, false); //For Printing to the Default Printer JasperPrintManager.printReport(jasperPrint, false); [/code] Link to comment Share on other sites More sharing options...
alimahran666 Posted November 1, 2018 Author Share Posted November 1, 2018 thank u very much for ur answerthis code is JasperPrintManager.printReport(jasperPrint, false); is print directally without using print button , i want to fire print putton so ? how can customizie print button on jasperviewer window to print default Link to comment Share on other sites More sharing options...
reportdev Posted November 1, 2018 Share Posted November 1, 2018 JasperViewer is just an implementation of JFrame. So you can try adding new buttons and action listeners to it. It was time consuming for me to find the Print button component in the Jframe.. So I have created a new button and added action listener which initiates the JasperPrintManager. final JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, con); JFrame frame = new JFrame("Report"); JButton b = new JButton("PrintToDefaultPrinter"); b.setBounds(500, 0, 250, 25); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { JasperPrintManager.printReport(jasperPrint, false); } catch (JRException e) { e.printStackTrace(); } } }); frame.add(b); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new JRViewer(jasperPrint)); frame.pack(); frame.setVisible(true);[/code] Link to comment Share on other sites More sharing options...
alimahran666 Posted November 1, 2018 Author Share Posted November 1, 2018 thank u very much my problem is solved Link to comment Share on other sites More sharing options...
alimahran666 Posted November 3, 2018 Author Share Posted November 3, 2018 i want to disable or remove print button form jasperviewer window and leave button print button that added it . how can ? Link to comment Share on other sites More sharing options...
alimahran666 Posted November 3, 2018 Author Share Posted November 3, 2018 i want to disable or remove print and save button from jasperviewer window and leave button print only that i added it . how can ? 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