Jump to content
Changes to the Jaspersoft community edition download ×

How can JasperReport print on Client\'s browser ?


krislioe

Recommended Posts

dear sirs,
I am new to Jasperreport.

In our JSF/JSP application we have requirement to print Invoice and Ticket  from client side on web browser.

We cannot accept the current solution using PDF because we dont want user to be able to save the PDF.

So this is the requirement :

1) User preview the report then click button "print", the report get printed to printer (Must Not use PDF here)

2) When user Click button "print" we want to execute Java code to update a table through JDBC call.

Can JasperReport fit these requirements ?

Thank you,
Krist
 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

I'm new to JasperReports, too, so this is just speculation.

One option might be using an applet.  It could be as simple as hooking up a JViewer to read the JPrint object from a separate query back to the server.  e.g. page A has a print button that starts an applet, which makes a request back to page B the server side.  Page B would return just the XML: JasperExportManager.exportReportToXml(print); and then back on the client side (in the applet):

// Do what you have to do to get the XML from the server as reportXml, and then ...JFrame frame = new JFrame(frameTitle);frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);try{	ByteArrayInputStream inputStream = new ByteArrayInputStream(reportXml.getBytes());	JRViewer viewer = new JRViewer(inputStream, true);	frame.add(BorderLayout.CENTER, viewer);	frame.setSize(1024, 748);	frame.setVisible(true);}catch (JRException e1){	e1.printStackTrace();}

This gives you a nice windowed preview of the report, with a convenient print button.  I haven't tried this in an applet, so you might have to make some use of jarsigner ... hope you have your certificate already!

Chris

Link to comment
Share on other sites

  • 5 months later...
  • 6 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...