Skip to content

Commit f56af57

Browse files
committed
update docs and examples
1 parent 554fc1c commit f56af57

File tree

5 files changed

+46
-37
lines changed

5 files changed

+46
-37
lines changed

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
# PHPJasper Examples
22

3-
How to use:
4-
5-
* Clone or download the repository
6-
* Run `composer install`
7-
* Execute the examples
3+
### How to use
4+
_Do you need Docker and Docker Compose installed in your machine_
5+
6+
* Clone or download the repository;
7+
* Run the commands into the path `/examples`:
8+
* `docker-compose up -d`;
9+
* `docker exec -it phpjasperExample composer install`.
10+
* `docker exec -it phpjasperExample sudo apk add ttf-dejavu`
811
---
12+
13+
### Examples
14+
_Use the command `docker exec -it phpjasperExample php index.php` to run examples_
15+
916
**Compile jrxml into .jasper**
1017

1118
`
@@ -20,7 +27,6 @@ $examples->compileExample();
2027

2128
`$examples->listParametersExample();`
2229

23-
2430
**Generate reports from a database**
2531

2632
`$examples->DbExample();`
@@ -29,10 +35,18 @@ $examples->compileExample();
2935

3036
`$examples->DbExampleWithSubReport();`
3137

32-
**Generate reports from a XML file**
38+
**Generate reports from an XML file**
3339

3440
`$examples->XMLExample();`
3541

3642
**Generate reports from a JSON file**
3743

38-
`$examples->JsonExample();`
44+
`$examples->JsonExample();`
45+
46+
### Folder structure
47+
48+
* compiled: Compiled .jasper files will be in this folder;
49+
* data_files: Contains data sources for examples;
50+
* input: Contains the reports `.jrxml` files;
51+
* output: Will have the results of the examples;
52+
* resources: Contains other files.

index.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
$examples = new Examples;
1111

1212
//Compile jrxml into .jasper
13-
//$examples->compileExample();
13+
$examples->compileExample();
1414

1515
//Process file .jrxml or .jasper
16-
//$examples->processExample();
16+
$examples->processExample();
1717

1818
//List Parameters-> .jrxml or .jasper
19-
//$examples->listParametersExample();
19+
$examples->listParametersExample();
20+
21+
//Generate reports from a XML file
22+
$examples->XMLExample();
23+
24+
//Generate reports from a JSON file
25+
$examples->JsonExample();
2026

2127
//Generate reports from a database
2228
//$examples->DbExample();
2329

2430
//Generate reports from a database with subreports
2531
//$examples->DbExampleWithSubReport();
26-
27-
//Generate reports from a XML file
28-
//$examples->XMLExample();
29-
30-
//Generate reports from a JSON file
31-
//$examples->JsonExample();

src/Examples.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,11 @@ class Examples
1212
{
1313
private $PHPJasper;
1414

15-
/**
16-
* Examples constructor.
17-
* @param null $PHPJasper
18-
*/
19-
public function __construct($PHPJasper = null)
15+
public function __construct()
2016
{
2117
$this->PHPJasper = new PHPJasper();
2218
}
2319

24-
2520
public function compileExample()
2621
{
2722
$input_file = __DIR__ . '/input/hello_world.jrxml';
@@ -148,4 +143,4 @@ public function JsonExample()
148143
$options
149144
)->execute();
150145
}
151-
}
146+
}

src/input/CancelAck.jrxml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,35 @@
3939
<property name="com.jaspersoft.studio.unit.height" value="px"/>
4040
</reportElement>
4141
<textElement textAlignment="Center">
42-
<font fontName="Arial" size="13" isBold="true"/>
42+
<font fontName="DejaVu Sans" size="13" isBold="true"/>
4343
</textElement>
4444
<text><![CDATA[Canceled Tax Documents]]></text>
4545
</staticText>
4646
<staticText>
4747
<reportElement uuid="cfef981f-fffa-4c5c-8dda-a8871f00a49f" x="244" y="57" width="256" height="18"/>
4848
<textElement textAlignment="Center">
49-
<font fontName="Arial" size="11" isBold="true"/>
49+
<font fontName="DejaVu Sans" size="11" isBold="true"/>
5050
</textElement>
5151
<text><![CDATA[Cancelation Acknowledgement]]></text>
5252
</staticText>
5353
<textField pattern="d/M/yyyy">
5454
<reportElement uuid="5f10c6b4-2a29-45c9-990d-1582d698e7ed" x="380" y="87" width="60" height="19"/>
5555
<textElement>
56-
<font fontName="Arial"/>
56+
<font fontName="DejaVu Sans"/>
5757
</textElement>
5858
<textFieldExpression><![CDATA[$V{Date}]]></textFieldExpression>
5959
</textField>
6060
<textField>
6161
<reportElement uuid="74d0c1e1-20e4-44c0-9530-593cb55f353a" x="440" y="87" width="60" height="19"/>
6262
<textElement>
63-
<font fontName="Arial"/>
63+
<font fontName="DejaVu Sans"/>
6464
</textElement>
6565
<textFieldExpression><![CDATA[$V{Hour}]]></textFieldExpression>
6666
</textField>
6767
<textField>
6868
<reportElement uuid="db8ca2dd-b146-4ef4-9bcf-6e2d151dcfb2" x="380" y="125" width="100" height="19"/>
6969
<textElement>
70-
<font fontName="Arial"/>
70+
<font fontName="DejaVu Sans"/>
7171
</textElement>
7272
<textFieldExpression><![CDATA[$F{VAT}]]></textFieldExpression>
7373
</textField>
@@ -95,14 +95,14 @@
9595
<textField pattern="d/M/yyyy">
9696
<reportElement uuid="90e35371-99b6-4ca7-a5f7-fe211244d76d" x="380" y="105" width="60" height="19"/>
9797
<textElement>
98-
<font fontName="Arial"/>
98+
<font fontName="DejaVu Sans"/>
9999
</textElement>
100100
<textFieldExpression><![CDATA[$V{Date}]]></textFieldExpression>
101101
</textField>
102102
<textField>
103103
<reportElement uuid="0032ffe3-aa1c-4e24-b7f2-fdfd305ff698" x="440" y="105" width="60" height="19"/>
104104
<textElement>
105-
<font fontName="Arial"/>
105+
<font fontName="DejaVu Sans"/>
106106
</textElement>
107107
<textFieldExpression><![CDATA[$V{Hour}]]></textFieldExpression>
108108
</textField>
@@ -159,7 +159,7 @@
159159
<rightPen lineWidth="0.1" lineStyle="Solid" lineColor="#B5B5B5"/>
160160
</box>
161161
<textElement>
162-
<font fontName="Arial"/>
162+
<font fontName="DejaVu Sans"/>
163163
</textElement>
164164
<textFieldExpression><![CDATA[$F{UUID}]]></textFieldExpression>
165165
</textField>
@@ -175,7 +175,7 @@
175175
<rightPen lineWidth="0.1" lineStyle="Solid" lineColor="#B5B5B5"/>
176176
</box>
177177
<textElement>
178-
<font fontName="Arial"/>
178+
<font fontName="DejaVu Sans"/>
179179
</textElement>
180180
<textFieldExpression><![CDATA[$F{StatusUUID}.equals("201") ? "Canceled" : $F{StatusUUID}.equals("202") ? "Previously Canceled" : $F{StatusUUID}.equals("203") ? "Invalid fot VAT number" : $F{StatusUUID}.equals("204") ? "Can't be canceled" : $F{StatusUUID}.equals("205") ? "ID doesn't exist" : "invalid error code"]]></textFieldExpression>
181181
</textField>
@@ -208,7 +208,7 @@
208208
<textField isStretchWithOverflow="true">
209209
<reportElement uuid="7ae79615-9f62-4509-960f-687837fdb7bf" x="50" y="16" width="460" height="15"/>
210210
<textElement>
211-
<font fontName="Arial"/>
211+
<font fontName="DejaVu Sans"/>
212212
</textElement>
213213
<textFieldExpression><![CDATA[$F{SignatureValue}]]></textFieldExpression>
214214
</textField>

src/input/hello_world.jrxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<staticText>
1515
<reportElement x="20" y="20" width="349" height="45" forecolor="#FFFFFF" uuid="2464c9ca-82a1-48c9-87ea-b68192294c4a"/>
1616
<textElement>
17-
<font fontName="Arial" size="34" isBold="true"/>
17+
<font fontName="DejaVu Sans" size="34" isBold="true"/>
1818
</textElement>
1919
<text><![CDATA[PHPjasper example]]></text>
2020
</staticText>
@@ -29,7 +29,7 @@
2929
<staticText>
3030
<reportElement x="14" y="19" width="521" height="30" uuid="6f85b46e-f5b1-4f07-b38c-aa0f6bf985e3"/>
3131
<textElement>
32-
<font fontName="Arial"/>
32+
<font fontName="DejaVu Sans"/>
3333
</textElement>
3434
<text><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum]]></text>
3535
</staticText>
@@ -43,7 +43,7 @@
4343
<staticText>
4444
<reportElement x="14" y="15" width="521" height="24" uuid="c15d0e17-2850-4010-b65a-e4822a371ba3"/>
4545
<textElement>
46-
<font fontName="Arial" size="15"/>
46+
<font fontName="DejaVu Sans" size="15"/>
4747
</textElement>
4848
<text><![CDATA[Hello World !!!]]></text>
4949
</staticText>

0 commit comments

Comments
 (0)