Jump to content
Changes to the Jaspersoft community edition download ×

JasperViewer customize print


Recommended Posts

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.JasperViewer

but iam don.t know

thanks u  more

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

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

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...