I have installed ubuntu server with php mysql webapplication. Also installed jasperserver 5.5.0 in the same server.
Now I have designed reports using iReports and placed in server /var/www/ directory. Now I want to display this report in pdf/xls in client's browser.
I have searched many guides, but doesnot work out for me. Can help me the step by step how to ?
Thank you, Thanika
First, you must add your reports to your instance of JasperServer. Once you've done this, each report will have a specific URI relative to its location on the report server.
You should then take a look at the PHP Client for JasperReports, which you can find on GitHub: https://github.com/Jaspersoft/jrs-rest-php-client
Once you've installed the PHP client, you will be able to make requests within your PHP application to obtain and display reports in whichever format you prefer (iframe, offer for download, etc)
An example to help you get started:
If you have a report located at the URI "/reports/MyReport" you will be able to display it to users in an HTML format using the following PHP code:
<?php require_once __DIR__ . "/vendor/autoload.php"; header('Content-Type: text/html'); use Jaspersoft\Client\Client; $c = new Client( "localhost", "8080", "jasperadmin", "jasperadmin", "/jasperserver-pro", "organization_1" ); $report = $c->reportService()->runReport('/reports/MyReport', 'html'); echo $report; ?>
In this simple example, a client connection is created and stored in $c using the credentials supplied in the instansiation. You can then use any of the services provided by Client to access various functionality of the JasperReports Server.
For displaying reports, you will want to use the report service. In the example above, we ask the client to provide the report located at the URI "/reports/MyReport" in HTML format. It is then stored in $report.
Since the report is in HTML, you can then display it simply by echoing the content of $report.