Why an empty report is being created in Jasper Reports - jasper-reports

I am new to Jasper Reports , cpuld anybody please tell me why an empty Report is being created inspite of data being resent in Database
please see this is my program
public class ReportDriver {
/**
* Constructor for ReportDriver
*/
public ReportDriver() {
}
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(
"jdbc:oracle:thin:#localhost:1521:orcle", "scott", "tiger");
JasperDesign jasperDesign = JRXmlLoader
.load("C:\\Documents and Settings\\Admin\\report5.jrxml");
JasperReport jasperReport = JasperCompileManager
.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(
jasperReport, null, con);
JasperViewer.viewReport(jasperPrint);
} catch (Exception ex) {
ex.printStackTrace();
String connectMsg = "Could not create the report ";
System.out.println(connectMsg);
}
}
}
This is my jrxml file
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report5" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<queryString language="SQL">
<![CDATA[select EMPNO , ENAME , JOB from emp]]>
</queryString>
<field name="EMPNO" class="java.math.BigDecimal"/>
<field name="ENAME" class="java.lang.String"/>
<field name="JOB" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch"/>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>

Your report is empty because that's exactly how it should be: Your jrxml does not include any elements to display. Try the following jrxml and see the difference:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report5" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<queryString language="SQL">
<![CDATA[select EMPNO , ENAME , JOB from emp]]>
</queryString>
<field name="EMPNO" class="java.math.BigDecimal"/>
<field name="ENAME" class="java.lang.String"/>
<field name="JOB" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{EMPNO}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{ENAME}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="40" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{JOB}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>

Related

How to send multiple datasets using node-jasper library?

I have a task to generate PDFs with nodeJS, so i am working with the node-jasper library.
what i want to know is how can i send multiple datasets in order to fill multiple charts. I can only send one dataset (the main dataset):/
here is my complete code:
const express = require('express')
var fs = require('fs')
const app = express()
const port = 5000
var jasper = require('node-jasper')({
path: './lib/jasperreports-6.10.0',
reports: {
hw: {
jasper: './jasperFiles/test.jasper',
jrxml: './reports/test.jrxml',
conn: 'in_memory_json'
}
},
});
app.get('/jasper1', (req, res) => {
var report = {
report: 'hw',
data: {
title: "test title",
dataset1: jasper.toJsonDataSource(
{
dados: [
{
c: "ar",
x: 'Arabe',
y: 20,
},
{
c: "en",
x: 'English',
y: 40,
}
]
},
'dados'
),
dataset2: jasper.toJsonDataSource(
{
dados: [
{
c: "eu",
x: 'Euro',
y: 15,
},
{
c: "usd",
x: 'Dollar',
y: 35,
}
]
},
'dados'
)
}
,
dataset:{},
}
var pdf = jasper.pdf(report);
res.set({
'Content-type': 'application/pdf',
'Content-Length': pdf.length
});
res.send(pdf)
});
app.listen(port, () => {
console.log('app is runing on port: ', port)
})
This the the report Design:
enter image description here
And This is the two datasets that i have created:
enter image description here
and this is my jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.10.0.final using JasperReports Library version 6.10.0-unknown -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d2376d66-daf9-486d-877e-cc7f2fe28426">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<subDataset name="dataset1" uuid="80298b05-e1fd-427e-b7b5-c6a9e571d151">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="x" class="java.lang.String"/>
<field name="y" class="java.lang.Integer"/>
<field name="c" class="java.lang.String"/>
</subDataset>
<subDataset name="dataset2" uuid="a4f9409d-a1fa-45a5-a00b-d2f95b31573e">
<queryString>
<![CDATA[]]>
</queryString>
<field name="x" class="java.lang.String"/>
<field name="y" class="java.lang.Integer"/>
<field name="c" class="java.lang.String"/>
</subDataset>
<parameter name="title" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="64" splitType="Stretch">
<staticText>
<reportElement x="50" y="0" width="103" height="64" uuid="6f999744-c4f9-48ef-a587-677dc644d77d"/>
<textElement>
<font size="26"/>
</textElement>
<text><![CDATA[Title]]></text>
</staticText>
<textField>
<reportElement x="140" y="10" width="100" height="30" uuid="e5a12f91-ddb4-445b-9f5b-57093703abaa"/>
<textFieldExpression><![CDATA[$P{title}]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="604" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
<pieChart>
<chart evaluationTime="Report">
<reportElement x="0" y="0" width="278" height="604" uuid="49052c41-6b67-42ed-9c84-c3089d3b2411"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset maxCount="10">
<dataset>
<datasetRun subDataset="dataset1" uuid="7466bccc-a18d-4c68-801f-caac7533de69"/>
</dataset>
<keyExpression><![CDATA[$F{c}]]></keyExpression>
<valueExpression><![CDATA[$F{y}]]></valueExpression>
<labelExpression><![CDATA[$F{x}]]></labelExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
<pieChart>
<chart evaluationTime="Report">
<reportElement x="278" y="0" width="277" height="604" uuid="9f438f49-3f14-44b9-81a4-5f475ff6ecb2"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset maxCount="10">
<dataset>
<datasetRun subDataset="dataset2" uuid="ce453374-bcf5-4b02-b8d9-35b263f143bc"/>
</dataset>
<keyExpression><![CDATA[$F{c}]]></keyExpression>
<valueExpression><![CDATA[$F{y}]]></valueExpression>
<labelExpression><![CDATA[$F{x}]]></labelExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
</band>
</detail>
<summary>
<band height="67" splitType="Stretch">
<staticText>
<reportElement x="180" y="10" width="151" height="51" uuid="da960c22-4947-49e0-9185-d2d39e21bcd7"/>
<textElement>
<font size="26"/>
</textElement>
<text><![CDATA[Footer]]></text>
</staticText>
</band>
</summary>
</jasperReport>
The problem is that when i run my code, the charts does not appear in the generated PDF, is this the right way to send datasets values ?
Can you help please ?
You need to declare the dataset1 and dataset2 parameters in the report and send them as data sources for the two chart subdatasets.
Like this (see the parameter definitions and the dataSourceExpression under datasetRun):
<parameter name="title" class="java.lang.String"/>
<parameter name="dataset1" class="net.sf.jasperreports.engine.JRDataSource"/>
<parameter name="dataset2" class="net.sf.jasperreports.engine.JRDataSource"/>
...
<detail>
<band height="604" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
<pieChart>
<chart evaluationTime="Report">
<reportElement x="0" y="0" width="278" height="604" uuid="49052c41-6b67-42ed-9c84-c3089d3b2411"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset maxCount="10">
<dataset>
<datasetRun subDataset="dataset1" uuid="7466bccc-a18d-4c68-801f-caac7533de69">
<dataSourceExpression><![CDATA[$P{dataset1}]]></dataSourceExpression>
</datasetRun>
</dataset>
<keyExpression><![CDATA[$F{c}]]></keyExpression>
<valueExpression><![CDATA[$F{y}]]></valueExpression>
<labelExpression><![CDATA[$F{x}]]></labelExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
<pieChart>
<chart evaluationTime="Report">
<reportElement x="278" y="0" width="277" height="604" uuid="9f438f49-3f14-44b9-81a4-5f475ff6ecb2"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset maxCount="10">
<dataset>
<datasetRun subDataset="dataset2" uuid="ce453374-bcf5-4b02-b8d9-35b263f143bc">
<dataSourceExpression><![CDATA[$P{dataset2}]]></dataSourceExpression>
</datasetRun>
</dataset>
<keyExpression><![CDATA[$F{c}]]></keyExpression>
<valueExpression><![CDATA[$F{y}]]></valueExpression>
<labelExpression><![CDATA[$F{x}]]></labelExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
</band>
</detail>

How to horizontally print a list in subreport in Jasper Report

I have a two models Customer and Order as follow:
class Customer{
private String customerName;
private List<Order> orders;
}
class Order{
private String orderName;
}
I am creating a pdf that lists all the customer name vertically and its corresponding orders horizontally which look like below:
customer1 order1 order2
customer2 order3 order4
.
.
.
where order1 and order2 belong to customer1 and order3 and order4 belong to customer2.
What I did is for each customer object, i will print the customer name and pass the orders list to another subreport and inside this subreport, i will print all of the element in this orders list but horizontally instead of vertically.
Here is my jrxml code:
My main report:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="epicsReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="98e422a6-47f1-4bf1-9436-b6cbfdc8c904">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="ordersSubReport" class="net.sf.jasperreports.engine.JasperReport"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="customerName" class="java.lang.String"/>
<field name="orders" class="java.util.List"/>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="25" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="270" height="25" uuid="26bf39b4-9072-4edc-a846-3141bff7da16">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="8d2c2571-e603-4eba-8048-3053e3282a99"/>
</reportElement>
<textFieldExpression><![CDATA[$F{customerName}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="312" y="0" width="200" height="25" uuid="b2675578-87cc-4a7b-8b5a-2c8af0fbde73"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{orders})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{ordersSubReport}]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
My subreport:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="skillsDataReport" columnCount="10" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="55" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c6d95fd0-d8af-4727-999c-9804a17721e4">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="orderName" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="25" splitType="Stretch">
<textField>
<reportElement x="9" y="0" width="100" height="25" uuid="1ac7d520-9918-4106-b4ad-1b446da6a01f"/>
<textFieldExpression><![CDATA[$F{orderName}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
As data source for main report I pass a list of customers to it: new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{customers})
And as data source for my subreport, for each customer object I pass a list of orders to it: new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{orders})
The codes were compiled successfully but the orders list were not shown as I expected. I see only the list of customerName are printed but not the orders list.
What did I do wrong here? Any help will be a big glue for me :)

Jaspersoft studio json data adapter book or subreport document is Empty

I am trying to do something really simple yet after searching for the past few days I could not find an answer, I need some help on this one.
What I am trying to do:
I have multiple reports so A4 portrait some landscape, some with just static text some with tables, some with tables and variables and I want to put merge them together.
They work 100% individually.
Tried to make a master report with subreports did not work, tried the book approach did not work, I always get Document is empty, or if I try to manipulate the data query I get all kind of weird stuff.
Now I will try to make this example as simple as possible.
JSON data: (New data Adapter)
{
"name": "Sample Name",
"people":[
{
"who": "Person 1"
},
{
"who": "Person 2"
},
{
"who": "Person 3"
}
]
}
Book master report:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Empty_Book" pageWidth="595" pageHeight="842" sectionType="Part" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" uuid="d2716064-8ae4-40cf-a575-33afba400e3a">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>
<property name="net.sf.jasperreports.print.create.bookmarks" value="true"/>
<queryString language="json">
<![CDATA[]]>
</queryString>
<detail>
<part uuid="69d6ca13-26f6-425f-bff9-395c5b9c183b">
<p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
<subreportParameter name="REPORT_CONNECTION">
<subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA["Blank_A4_2.jasper"]]></subreportExpression>
</p:subreportPart>
</part>
<part uuid="055c9f89-88b4-4270-b6ef-addb2eac3e56">
<p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
<subreportParameter name="REPORT_CONNECTION">
<subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA["Blank_A4_Landscape_1.jasper"]]></subreportExpression>
</p:subreportPart>
</part>
</detail>
</jasperReport>
Blank_A4_2.jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bd2bd70c-5a0d-4c3f-b81d-4d5d7731153d">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>
<queryString language="json">
<![CDATA[]]>
</queryString>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="name"/>
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="150" y="30" width="100" height="30" uuid="eef5f1dc-3d96-4008-8321-ef0be92d42d4"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="50" y="30" width="100" height="30" uuid="cbe6173f-5399-45ec-926b-ff6f48b4fb0c"/>
<text><![CDATA[name]]></text>
</staticText>
</band>
</detail>
</jasperReport>
Blank_A4_Landscape_1.jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_Landscape_1" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="62f06d09-42b5-4471-baa5-5aed60cc5fc4">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>
<subDataset name="Dataset1" uuid="eb54ec0d-0c60-44af-8476-e44f40560dee">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>
<queryString language="json">
<![CDATA[people]]>
</queryString>
<field name="who" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="who"/>
<fieldDescription><![CDATA[who]]></fieldDescription>
</field>
</subDataset>
<queryString language="JSON">
<![CDATA[]]>
</queryString>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="name"/>
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="175">
<textField>
<reportElement x="132" y="81" width="100" height="30" uuid="5cce1f44-2a8b-42ad-a03d-4c294f02d31c"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="140" splitType="Stretch">
<componentElement>
<reportElement x="110" y="45" width="200" height="40" uuid="75a06812-f9a0-4b0f-9a08-efec60d0b555"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Dataset1" uuid="acd62160-c07c-4c00-b6b4-9ef001d1585d">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("people")]]></dataSourceExpression>
</datasetRun>
<jr:column width="200" uuid="253a610c-a780-4690-8cce-8a03597ef016">
<jr:detailCell height="30">
<textField>
<reportElement x="0" y="0" width="200" height="30" uuid="910a7e24-c02b-4b21-8c9d-6a3dfda21794"/>
<textFieldExpression><![CDATA[$F{who}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
Tested all files before posting, individually they work, I have no params to send to the subreports, I tried looping over the array and still nothing I always get document is Empty no matter what I do.
Passing the REPORT_CONNECTION to each subreport part has no effect. It's value will be non-null for JDBC connections only. So there's no reason to pass it.
You could have your setup running by tying each subreport to the Data Adapter file:
Export the Data Adapter to a file, say JSON_DA.xml, on the same level with your reports.
Add this property to each of the subreports:
<property name="net.sf.jasperreports.data.adapter" value="JSON_DA.xml"/>
(This could also be done by setting the Default Data Adapter in the Report Properties tab)
Recompile each subreport then preview the Master report again.
All this is necessary because JasperSoft Studio does not inject the Data Adapter into each subreport at runtime. It only injects it when each report is individually run(previewed) by automatically setting the com.jaspersoft.studio.data.defaultdataadapter property.

Jasper report unicode font not showing in PDF

I am using jasper report with Spring MVC. I have generated font.jar from jaspersoft studio 6.6.0 and add it to my application classpath. I am trying to use vrinda.ttf and sutonnyOMJ.ttf.
While the report is rendered properly in jasper studio, when I am using it from my application no unicode fonts are showing for PDF export. For excel export all values are showing properly but pdf is not working.
Font Family from my custom font.jar
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="vrinda">
<normal><![CDATA[fonts/vrinda/vrinda.ttf]]></normal>
<pdfEncoding><![CDATA[Identity-H]]></pdfEncoding>
<pdfEmbedded><![CDATA[true]]></pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">vrinda</export>
<export key="net.sf.jasperreports.xhtml">vrinda</export>
</exportFonts>
</fontFamily>
<fontFamily name="sutonny">
<normal><![CDATA[fonts/sutonny/SutonnyOMJ.ttf]]></normal>
<bold><![CDATA[fonts/sutonny/SutonnyMJ-Bold.ttf]]></bold>
<italic><![CDATA[fonts/sutonny/SutonnyMJ-Italic.ttf]]></italic>
<boldItalic><![CDATA[fonts/sutonny/SutonnyMJ-BoldItalic.ttf]]></boldItalic>
<pdfEncoding><![CDATA[Identity-H]]></pdfEncoding>
<pdfEmbedded><![CDATA[true]]></pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">SutonnyOMJ</export>
<export key="net.sf.jasperreports.xhtml">SutonnyOMJ</export>
</exportFonts>
</fontFamily>
</fontFamilies>
JRXML:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="myName" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a43ee182-4df8-4ea4-b26f-b8b21078c9d1">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="dbname"/>
<queryString language="SQL">
<![CDATA[Query]]>
</queryString>
<field name="ClientName" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="ClientName"/>
<property name="com.jaspersoft.studio.field.tree.path" value="Table"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch">
<textField>
<reportElement x="20" y="5" width="500" height="30" uuid="f4900f30-da32-4cec-9142-10b111debcf3"/>
<textElement>
<font fontName="Vrinda" size="26"/>
</textElement>
<textFieldExpression><![CDATA["\u09AA\u09CD\u09B0\u09A4\u09BF\u09AC\u09C7\u09A6\u09A8"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch">
<staticText>
<reportElement x="82" y="0" width="100" height="30" uuid="b35f8d0e-5c47-46c7-b71c-c63dd7706724">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="9609ebcc-b3ae-4997-92b2-9aa48843434a"/>
</reportElement>
<textElement>
<font size="26"/>
</textElement>
<text><![CDATA[ClientName]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="82" y="64" width="308" height="30" uuid="ba9cab6a-2688-4601-bedb-3b62913a2cfb">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="9609ebcc-b3ae-4997-92b2-9aa48843434a"/>
</reportElement>
<textElement>
<font fontName="Vrinda" size="26"/>
</textElement>
<textFieldExpression><![CDATA[$F{ClientName}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
Java Code:
JasperReport jasperReport = JasperCompileManager.compileReport(reportSourceFile);
JasperPrint print = JasperFillManager.fillReport(jasperReport, params, reportRequestDTO.getConnection());
JRPdfExporter exporter = new JRPdfExporter();
ExporterInput exporterInput = new SimpleExporterInput(print);
exporter.setExporterInput(exporterInput);
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(path);
exporter.setExporterOutput(exporterOutput);
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
exporter.setConfiguration(configuration);
exporter.exportReport();
pom.xml
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.5.1</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.0.0</version>
</dependency>
Excel Image for header unicode (Which is not showing in PDF)

How to compile a Jasper jrxml file containing a reference to a webservice data adapter with Jasper library

One of my clients has creating a report in Jasper Studio. In the report he has used a webservice datasource which comes with a corresponding data adapter. He uses this datasource to query a RESTful API. The jrxml file is given below:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6581b4b3-5a83-4a40-b2a1-091d3e949e06">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapter.xml"/>
<queryString language="WebServiceQuery">
<![CDATA[{
"getparameters" : { },
"fields" : [ {
"name" : "commercialCode",
"expression" : "commercialCode"
}, {
"name" : "classification",
"expression" : "classification"
} ],
"options" : {
"contentType" : "application/json",
"rootPath" : "_embedded.airportList",
"baseUrl" : ""
},
"headersMap" : { },
"queryData" : "",
"GETParameters" : { }
}]]>
</queryString>
<field name="commercialCode" class="java.lang.String"/>
<field name="classification" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="55" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="62" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="0" y="20" width="100" height="30" uuid="fed44789-e146-4b33-9f10-2f88eec34e8b"/>
<textFieldExpression><![CDATA[$F{commercialCode}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
The report displayed above references also a data adapter, which is shown below:
<?xml version="1.0" encoding="UTF-8" ?>
<webServiceDataAdapter class="com.jaspersoft.webservice.data.WebServiceDataAdapterImpl">
<name>Airports</name>
<wsUri>http://localhost:8080/api/airports</wsUri><authType>none</authType><verb>get</verb><language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://java.sun.com" xsi:type="java:java.lang.String">json</language></webServiceDataAdapter>
I am not sure how I can compile this report using the Jasper report library. Any help would be greatly appreciated!
With pure JasperReports i think its no possible.
There is Web Service Data Source extension to Jaspersoft (Studio, Server, Library).
I wan't been able to find a way to use it with pure JasperReport Library yet. Installation guides are only for Studio or Server and with them it works fine.
But when you download it from this website you have also folder "JR" with 3 jars, i guess they should contain classes providing support to JasperReport Library
I think it should be something which implements JRDataSource to pass it
JasperFillManager.fillReport(String sourceFileName, Map params, JRDataSource dataSource)