Skip to content

Instantly share code, notes, and snippets.

@nunomazer
Last active January 17, 2020 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nunomazer/8421402 to your computer and use it in GitHub Desktop.
Save nunomazer/8421402 to your computer and use it in GitHub Desktop.
Using PHP client for Jaspersoft Server
<?php
/* Initializing client */
require_once "client/JasperClient.php";
$client = new Jasper\JasperClient('localhost', // Hostname
8080, // Port
'jasperadmin', // Username
'jasperadmin', // Password
'/jasperserver-pro', // Base URL
'organization_1'); // Organization (pro only)
<?php
$report_options = $client->getReportOptions('/reports/samples/Cascading_multi_select_report');
foreach($report_options as $ro) {
echo $ro->getLabel() . "
";
}
<?php
$report = $client->runReport('/reports/samples/AllAccounts', 'pdf');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=report.pdf');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . strlen($report));
header('Content-Type: application/pdf');
echo $report;
<?php
$controls = array('Country_multi_select' => array('USA', 'Mexico'),
'Cascading_state_multi_select' => array('CA', 'OR'));
$report = $client->runReport('/reports/samples/Cascading_multi_select_report','html', null, $controls);
echo $report;
<?php
$report = $client->runReport('/reports/samples/AllAccounts', 'html');
// The URI string could also be found from a resourceDescriptor object using the getUriString() method
echo $report;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment