Jump to content
We've recently updated our Privacy Statement, available here ×

Getting total number of pages using PHP/SOAP


derek_ricca

Recommended Posts

Ok, I saw in another thread that there's a fairly simple way in Java to get the total number of pages (identified in a jasper report as $P{PAGE_COUNT}.

 

My question is how do I export that number through a PHP/SOAP interface? I'm trying to make a scrollable interface (ie: "Page 1|2|3|4" or something). The PHP example doesn't really help at all in this instance. Thanks.

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

I know there is module that you can integrate Java into PHP, but I never used PHP. If you know how to do, integrate following Java code:

 

//this is comment

//jasperPrint is JasperPrint Object.

int total_pages=jasperPrint.getPages().size();

Link to comment
Share on other sites

Since nobody had any idea how to do this, I figured I would post up the solution I came up with. It's not perfect but it works. Maybe the writers of JasperReports can include it, it's pretty simple.

 

Anyway, I simply created a Java class which extends the ManagementService class (part of the com.jaspersoft.jasperserver.ws.axis2 package), overwriting the "runReport" function with pretty much the same thing, except I add the following lines right before addAdditionalAttachmentsForReport(jasperPrint, attachments, format, new StringBuffer(new String(bos.toByteArray())));:

 

Code:

num_pages = jasperPrint.getPages().size();
or.setMessage("Total pages: " + num_pages);

 

This just returns the number of pages in the operation result. I think this should have definitely been a standard part of HTML export, since otherwise it's pretty much impossible to get the total number of pages unless it's through a JSP (which I'm not using and many other people don't use either), and kind of stupid to force the user to guess or check for an error every time they increment the page they're displaying.

 

If anyone needs the class file just reply and I'll post it up.

 

Post edited by: derek_ricca, at: 2007/08/10 19:16

Post edited by: derek_ricca, at: 2007/08/10 19:18

Link to comment
Share on other sites

  • 2 weeks 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...