Skip to content
This repository was archived by the owner on Oct 25, 2022. It is now read-only.

Commit c798e8a

Browse files
authored
Merge pull request #80 from cossou/pr/79
Pr/79
2 parents 2ed2c0c + 717ff94 commit c798e8a

File tree

146 files changed

+4843
-5186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+4843
-5186
lines changed

README.md

+93-23
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ First we need to compile our `JRXML` file into a `JASPER` binary file. We just h
5050
**Note:** You don't need to do this step if you are using *Jaspersoft Studio*. You can compile directly within the program.
5151

5252
```php
53-
JasperPHP::compile(base_path() . '/vendor/cossou/jasperphp/examples/hello_world.jrxml')->execute();
53+
JasperPHP::compile(base_path('/vendor/cossou/jasperphp/examples/hello_world.jrxml'))->execute();
5454
```
5555

5656
This commando will compile the `hello_world.jrxml` source file to a `hello_world.jasper` file.
@@ -63,10 +63,10 @@ Now lets process the report that we compile before:
6363

6464
```php
6565
JasperPHP::process(
66-
base_path() . '/vendor/cossou/jasperphp/examples/hello_world.jasper',
66+
base_path('/vendor/cossou/jasperphp/examples/hello_world.jasper'),
6767
false,
68-
array("pdf", "rtf"),
69-
array("php_version" => phpversion())
68+
array('pdf', 'rtf'),
69+
array('php_version' => phpversion())
7070
)->execute();
7171
```
7272

@@ -80,7 +80,7 @@ Querying the jasper file to examine parameters available in the given jasper rep
8080

8181
```php
8282
$output = JasperPHP::list_parameters(
83-
base_path() . '/vendor/cossou/jasperphp/examples/hello_world.jasper'
83+
base_path('/vendor/cossou/jasperphp/examples/hello_world.jasper')
8484
)->execute();
8585

8686
foreach($output as $parameter_description)
@@ -93,10 +93,10 @@ We can also specify parameters for connecting to database:
9393

9494
```php
9595
JasperPHP::process(
96-
base_path() . '/vendor/cossou/jasperphp/examples/hello_world.jasper',
96+
base_path('/vendor/cossou/jasperphp/examples/hello_world.jasper'),
9797
false,
98-
array("pdf", "rtf"),
99-
array("php_version" => phpversion()),
98+
array('pdf', 'rtf'),
99+
array('php_version' => phpversion()),
100100
array(
101101
'driver' => 'postgres',
102102
'username' => 'vagrant',
@@ -169,38 +169,40 @@ Add `JasperPHP\JasperPHPServiceProvider::class` to config `config/app.php` in se
169169
File `config/app.php`
170170

171171
```php
172-
<?php
173-
.......
174-
.......
172+
<?php
173+
//...
175174
'providers' => [
176-
.......
175+
//...
177176
Illuminate\Translation\TranslationServiceProvider::class,
178177
Illuminate\Validation\ValidationServiceProvider::class,
179178
Illuminate\View\ViewServiceProvider::class,
180-
//insert jasper service provider here
179+
180+
//insert jasper service provider here
181181
JasperPHP\JasperPHPServiceProvider::class
182182
],
183-
......
184-
......
185183

186184
```
187185

188-
Uses in Controller by add `use JasperPHP` after namespace
186+
Uses in Controller by adding `use JasperPHP` after namespace
189187
```php
190188
<?php
191189
namespace App\Http\Controllers;
190+
192191
use JasperPHP; // put here
193-
......
194-
......
192+
193+
class SomethingController
194+
{
195+
//...
196+
195197
public function generateReport()
196198
{
197199
//jasper ready to call
198-
JasperPHP::compile(base_path() . '/vendor/cossou/jasperphp/examples/hello_world.jrxml')->execute();
200+
JasperPHP::compile(base_path('/vendor/cossou/jasperphp/examples/hello_world.jrxml'))->execute();
199201
}
200-
......
202+
}
201203
```
202204

203-
Uses in Route
205+
Use in Route
204206
```php
205207
use JasperPHP\JasperPHP as JasperPHP;
206208

@@ -233,7 +235,7 @@ Route::get('/', function () {
233235
Add to your `app/config/app.php` providers array:
234236

235237
```php
236-
'JasperPHP\JasperPHPServiceProvider',
238+
'JasperPHP\JasperPHPServiceProvider',
237239
```
238240
Now you will have the `JasperPHP` alias available.
239241

@@ -245,7 +247,75 @@ We ship the [MySQL connector](http://dev.mysql.com/downloads/connector/j/) (v5.1
245247

246248
We ship the [PostgreSQL](https://jdbc.postgresql.org/) (v9.4-1203) in the `/src/JasperStarter/jdbc/` directory.
247249

248-
Note: Laravel uses `pgsql` driver name instead of `postgres`.
250+
Note: Laravel uses `pgsql` driver name instead of `postgres`.
251+
252+
### JSON
253+
254+
Source file example:
255+
256+
```json
257+
{
258+
"result":{
259+
"id":26,
260+
"reference":"0051711080021460005",
261+
"account_id":1,
262+
"user_id":2,
263+
"date":"2017-11-08 00:21:46",
264+
"type":"",
265+
"gross":138,
266+
"discount":0,
267+
"tax":4.08,
268+
"nett":142.08,
269+
"details":[
270+
{"id":26, "line": 1, "product_id": 26 },
271+
]
272+
},
273+
"options":{
274+
"category":[
275+
{"id":3,"name":"Hair care","service":0,"user_id":1, },
276+
],
277+
"default":{
278+
"id":1,"name":"I Like Hairdressing",
279+
"description":null,
280+
"address":null,
281+
"website":"https:\/\/www.ilikehairdressing.com",
282+
"contact_number":"+606 601 5889",
283+
"country":"MY",
284+
"timezone":"Asia\/Kuala_Lumpur",
285+
"currency":"MYR",
286+
"time_format":"24-hours",
287+
"user_id":1
288+
}
289+
}
290+
}
291+
```
292+
293+
Using Laravel:
294+
295+
```php
296+
public function generateReceipt($id) {
297+
298+
$datafile = base_path('/storage/jasper/data.json');
299+
$output = base_path('/storage/jasper/data'); //indicate the name of the output PDF
300+
JasperPHP::process(
301+
base_path('/resources/reports/taxinvoice80.jrxml'),
302+
$output,
303+
array("pdf"),
304+
array("msg"=>"Tax Invoice"),
305+
array("driver"=>"json", "json_query" => "data", "data_file" => $datafile)
306+
)->execute();
307+
}
308+
```
309+
310+
Some hack to JasperReport datasource is required. You need to indicate datasource expression for each table, list, and subreport.
311+
312+
```xml
313+
<datasetRun subDataset="invoice_details" uuid="a91cc22b-9a3f-45eb-9b35-244890d35fc7">
314+
<dataSourceExpression>
315+
<![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("result.details")]]>
316+
</dataSourceExpression>
317+
</datasetRun>
318+
```
249319

250320
## Performance
251321

src/JasperPHP/JasperPHP.php

+6
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ public function process($input_file, $output_file = false, $format = array("pdf"
127127

128128
if ( isset($db_connection['db_sid']) && !empty($db_connection['db_sid']) )
129129
$command .= ' --db-sid ' . $db_connection['db_sid'];
130+
131+
if ( isset($db_connection['json_query']) && !empty($db_connection['json_query']) )
132+
$command .= ' --json-query ' . $db_connection['json_query'];
133+
134+
if ( isset($db_connection['data_file']) && !empty($db_connection['data_file']) )
135+
$command .= ' --data-file ' . $db_connection['data_file'];
130136

131137
}
132138

src/JasperStarter/CHANGES

+34
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
22
JasperStarter - Running JasperReports from command line
33
========================================================
44

5+
Release Notes - JasperStarter - Version 3.2.1
6+
---------------------------------------------
7+
8+
** Task
9+
* [JAS-109] - Include JasperReports-6.4.3
10+
11+
12+
Release Notes - JasperStarter - Version 3.2.0
13+
---------------------------------------------
14+
15+
** Bug
16+
* [JAS-96] - Enable JavaScript in expression
17+
* [JAS-99] - jasperreports-functions not in maven central
18+
* [JAS-100] - Pipeline build failed: Font "Arial" is not available to the JVM
19+
* [JAS-101] - Pipeline build failed: net.sf.launch4j.ExecException: java.io.IOException: Cannot run program
20+
* [JAS-107] - JasperStarter could not run reports with Barcode4J barcodes
21+
22+
** Task
23+
* [JAS-108] - Include JasperReports 6.4.1
24+
25+
26+
Release Notes - JasperStarter - Version 3.1.0
27+
---------------------------------------------
28+
29+
** New Feature
30+
* [JAS-83] - JSON file as a data source
31+
32+
** Task
33+
* [JAS-95] - Include JasperReports 6.4.0
34+
35+
** Improvement
36+
* [JAS-84] - How to pass $P{XML_DATA_DOCUMENT} to sub report - additional documentation
37+
38+
539
Release Notes - JasperStarter - Version 3.0.0
640
---------------------------------------------
741

src/JasperStarter/NOTICE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
JasperStarter - Running JasperReports from command line
3-
Copyright 2012, 2013, 2014 Cenote GmbH
3+
Copyright 2012, 2013, 2014, 2015 Cenote GmbH
44

55
This product includes software developed at:
66

src/JasperStarter/README.md

+22-23
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ JasperStarter - Running JasperReports from command line
55
JasperStarter is an opensource command line launcher and batch compiler for
66
[JasperReports][].
77

8+
The official homepage is [jasperstater.cenote.de][].
9+
810
It has the following features:
911

10-
* Run any JasperReport that needs a jdbc, csv, xml or empty datasource
12+
* Run any JasperReport that needs a jdbc, csv, xml, json or empty datasource
1113
* Use with any database for which a jdbc driver is available
14+
* Run reports with subreports
1215
* Execute reports that need runtime parameters. Any parameter whose class has
1316
a string constructor is accepted. Additionally the following types are
1417
supported or have special handlers:
@@ -20,27 +23,25 @@ It has the following features:
2023
* Export to file in the following formats:
2124
* pdf, rtf, xls, xlsMeta, xlsx, docx, odt, ods, pptx, csv, csvMeta, html, xhtml, xml, jrprint
2225
* Export multiple formats in one commanding call
23-
* Compile, Print and export in one commanding call
26+
* Compile, print and export in one commanding call
2427
* View, print or export previously filled reports (use jrprint file as input)
2528
* Can compile a whole directory of .jrxml files.
2629
* Integrate in non Java applications (for example PHP, Python)
2730
* Binary executable on Windows
2831
* Includes JasperReports so this is the only tool you need to install
2932

30-
Requirements
33+
Requirements:
3134

32-
* Java 1.6 or higher.
35+
* Java 1.6 or higher
3336
* A JDBC 2.1 driver for your database
3437

3538

3639
### Quickstart
3740

38-
* Download JasperStarter from [Sourceforge][]
41+
* Download JasperStarter from [Sourceforge][].
3942
* Extract the distribution archive to any directory on your system.
40-
* Add the _./bin_ directoy of your installation to your searchpath.
41-
42-
* or just invoke _setup.exe_ on Windows
43-
43+
* Add the _./bin_ directory of your installation to your searchpath (on
44+
Windows: invoke setup.exe).
4445
* Put your jdbc drivers in the _./jdbc_ directory of your installation or
4546
use _\--jdbc-dir_ to point to a different directory.
4647

@@ -69,7 +70,7 @@ archive or read the [Usage][] page online.
6970

7071
### Release Notes
7172

72-
See CHANGES file for a history of changes.
73+
See [Changes] for a history of changes.
7374

7475

7576
#### Known Bugs
@@ -94,20 +95,16 @@ project website is hosted at [Sourceforge][].
9495

9596
JasperStarter is build with [Maven][].
9697

97-
Unfortunately one dependency (jasperreports-functions) is not provided
98-
in a public maven repository so you must add it to your local maven
99-
repo:
98+
On Linux 64 bit the launch4j-maven-plugin may fail. You need the folloing libs in a 32 bit version:
99+
100+
* z1
101+
* ncurses5
102+
* bz2-1.0
100103

101-
# Download jasperreports-functions-6.0.4.jar from
102-
# https://sourceforge.net/projects/jasperreports/files/jasperreports/
103-
$ jar xvf jasperreports-functions-6.0.4.jar META-INF/maven/net.sf.jasperreports/jasperreports-functions/pom.xml
104-
$ mvn install:install-file -Dfile=jasperreports-functions-6.0.4.jar -DpomFile=META-INF/maven/net.sf.jasperreports/jasperreports-functions/pom.xml
104+
On Ubuntu 14.04 for example use this command:
105105

106-
See https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
106+
$ sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
107107

108-
It is possible to compile JasperStarter without this dependency but users
109-
will run into errors if they use specific functions in their reports.
110-
So there is a test that fails if jasperreports-functions is not available.
111108

112109
To get a distribution package run:
113110

@@ -148,11 +145,11 @@ or
148145
During development you might want not to be annoyed by tests. So the following
149146
options are useful:
150147

151-
$ package -P dev -D skipTests
148+
$ mvn package -P dev -D skipTests
152149

153150
or
154151

155-
$ package -P dev -D maven.test.failure.ignore=true
152+
$ mvn package -P dev -D maven.test.failure.ignore=true
156153

157154
To run JasperStarter from within your IDE add _\--jdbc-dir jdbc_ to the argument
158155
list of your run configuration. Otherwise you will get an error:
@@ -179,6 +176,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179176
See the License for the specific language governing permissions and
180177
limitations under the License.
181178

179+
[jasperstater.cenote.de]:http://jasperstarter.cenote.de/
182180
[JasperReports]:http://community.jaspersoft.com/project/jasperreports-library
183181
[Maven]:http://maven.apache.org/
184182
[Sourceforge]:http://sourceforge.net/projects/jasperstarter/
@@ -188,3 +186,4 @@ limitations under the License.
188186
[Issuetracker]:https://cenote-issues.atlassian.net/browse/JAS
189187
[Usage]:http://jasperstarter.sourceforge.net/usage.html
190188
[Issues]:https://cenote-issues.atlassian.net/browse/JAS
189+
[Changes]:changes.html
545 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)