Skip to content

Commit 5aec166

Browse files
author
geekcom
committed
Updated README.md
1 parent e7daba9 commit 5aec166

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

README.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ foreach($output as $parameter_description)
161161
print $parameter_description . '<pre>';
162162
```
163163

164-
###Advanced example
164+
###Advanced example 1
165165

166166
We can also specify parameters for connecting to database:
167167

@@ -190,7 +190,6 @@ $jasper->process(
190190
)->execute();
191191
```
192192

193-
194193
###Using JasperPHP with Laravel 5.2!
195194

196195
1. Install [Composer](http://getcomposer.org) if you don't have it.
@@ -245,6 +244,54 @@ Route::get('/reports', function () {
245244
In this example we generate reports pdf, rtf and xml.
246245

247246

247+
###Additional Information - Reports from a xml in Laravel 5.2
248+
249+
See how easy it is to generate a report with a source an xml file:
250+
251+
```php
252+
253+
use JasperPHP\JasperPHP;
254+
255+
public function xmlToPdf()
256+
{
257+
$output = public_path() . '/report/'.time().'_CancelAck';
258+
$output = public_path() . '/report/'.time().'_CancelAck';
259+
$ext = "pdf";
260+
261+
\JasperPHP::process(
262+
public_path() . '/report/CancelAck.jrxml',
263+
$output,
264+
array($ext),
265+
array(),
266+
array('data_file' => public_path() . '/report/CancelAck.xml', 'driver' => 'xml', 'xml_xpath' => '/CancelResponse/CancelResult/ID'),
267+
false,
268+
false
269+
)->execute();
270+
271+
header('Content-Description: File Transfer');
272+
header('Content-Type: application/octet-stream');
273+
header('Content-Disposition: attachment; filename='.time().'_CancelAck.'.$ext);
274+
header('Content-Transfer-Encoding: binary');
275+
header('Expires: 0');
276+
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
277+
header('Content-Length: ' . filesize($output.'.'.$ext));
278+
flush();
279+
readfile($output.'.'.$ext);
280+
unlink($output.'.'.$ext);
281+
282+
}
283+
```
284+
**Note:**
285+
286+
To use the example above you must copy the sample files located at:
287+
288+
**\vendor\lavela\phpjasper\src\JasperStarter\examples\CancelAck.jrxml**
289+
and
290+
**\vendor\lavela\phpjasper\src\JasperStarter\examples\CancelAck.xml**
291+
to folder:
292+
**\public\report**
293+
294+
248295
###MySQL
249296

250297
We ship the [MySQL connector](http://dev.mysql.com/downloads/connector/j/) (v5.1.34) in the `/src/JasperStarter/jdbc/` directory.

0 commit comments

Comments
 (0)