Jasper report unicode font not showing in PDF - jasper-reports

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)

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>

Why so much unused space, engine is skipping to a new page even if a lot of data could fit on the current page

I use jasper studio 6.17 and jasper library 6.17 and I have too much unused white space at the end of every page. I placed a image down to show the problem. So after record 21 there is a lot of free space that could easily fit records 22,23 and 24 but the space is not used, these records are displayed directly on page 2.
This is the jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.17.0.final using JasperReports Library version 6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd -->
<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="results" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isFloatColumnFooter="true">
<field name="text" class="java.lang.String"/>
<field name="image" class="java.awt.Image"/>
<detail>
<band height="130" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="595" height="29" isRemoveLineWhenBlank="true"/>
<box padding="0">
<pen lineWidth="1.25" lineStyle="Solid" lineColor="#030303"/>
</box>
<textElement>
<font fontName="DejaVu Sans" isBold="true"/>
<paragraph lineSpacingSize="0.0"/>
</textElement>
<textFieldExpression><![CDATA[$F{text}]]></textFieldExpression>
</textField>
<image>
<reportElement x="0" y="29" width="190" height="100" isRemoveLineWhenBlank="true"/>
<box>
<pen lineWidth="2.0" lineColor="#030303"/>
</box>
<imageExpression><![CDATA[$F{image}]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
And this is the full java code:
public class JasperBAM {
public static void main(String[] args) {
try {
List<BAMResult> bhs = BAMResult.getBAMResults();
JasperPrint jasperPrint = JasperFillManager.fillReport("JasperReports/results.jasper", null, new JRBeanCollectionDataSource(bhs));
OutputStream outputStream = new FileOutputStream(new File("BAM.pdf"));
JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
} catch (Exception ex) {
Logger.getLogger(JasperBAM.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public class BAMResult {
private String text;
private BufferedImage image;
public void settext(String text){this.text=text;}
public String gettext(){return text;}
public void setimage(){
try {
image=ImageIO.read(new File("image.png"));
} catch (IOException ex) {
Logger.getLogger(BAMResult.class.getName()).log(Level.SEVERE, null, ex);
}
}
public BufferedImage getimage() {
return image;
}
public static List<BAMResult> getBAMResults() {
try {
List<BAMResult> brs = new ArrayList<>();
for(int i=1; i<100; i++) {
BAMResult nt = new BAMResult();
nt.settext("record "+i);
if (i % 20==0){
nt.setimage();
}
brs.add(nt);
}
return brs;
} catch (Exception ex) {
Logger.getLogger(JasperBAM.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
}
UPDATE 1
I tried to set the the "split type" of the detail band to "Immediate" but the space still appears.
UPDATE 2
The problem is not related to the image field, I tried to put a text field in the place of the image and the problem is the same.
The decreasing of band height (that you have set to 130) is something that only happens in newer versions of jasper reports. The old layout concept was that you can not decrease the band height you can only increase it. Hence in older versions of jasper report every record would have had a minimum height of 130 (blank space under every record when image is not present)
I think what you are seeing is a "bug" when they are calculating the avviabile space for the detail band before page break, hence they are not considering that your band can dynamically decrease since element can be removed inside the band when rendered.
My suggestion is to always use the "old" design idea, only let band height increase.
You can easily achieve this by either using a frame or multiple detail bands
The frame solution
The idea is to put objects in frame that you set to minimum height so that you can reduce the detail band heights to this. The frame can then overflow and with that stretch the detail band when necessary.
<?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="results" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isFloatColumnFooter="true" uuid="176d8296-c530-48d6-85dc-11c41dce9f06">
<field name="text" class="java.lang.String"/>
<field name="image" class="java.awt.Image"/>
<detail>
<band height="30" splitType="Stretch">
<frame>
<reportElement x="0" y="0" width="595" height="29" uuid="7b3d35fe-eddb-4d8d-8016-6496b706950b">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="595" height="29" isRemoveLineWhenBlank="true" uuid="92b46a19-42c0-42f2-846a-3c7a7aaf0e2a"/>
<box padding="0">
<pen lineWidth="1.25" lineStyle="Solid" lineColor="#030303"/>
</box>
<textElement>
<paragraph lineSpacingSize="0.0"/>
</textElement>
<textFieldExpression><![CDATA[$F{text}]]></textFieldExpression>
</textField>
<image>
<reportElement x="0" y="29" width="190" height="100" isRemoveLineWhenBlank="true" uuid="1dc15e42-01a4-413f-b04e-30b8d0437e36"/>
<box>
<pen lineWidth="2.0" lineColor="#030303"/>
</box>
<imageExpression><![CDATA[$F{image}]]></imageExpression>
</image>
</frame>
</band>
</detail>
</jasperReport>
Multiple detail band solution
Use print expression on detail band to print or not print a band, in your case print it only when the image is aviaibile.
<?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="results" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isFloatColumnFooter="true" uuid="176d8296-c530-48d6-85dc-11c41dce9f06">
<field name="text" class="java.lang.String"/>
<field name="image" class="java.awt.Image"/>
<detail>
<band height="30" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="595" height="29" isRemoveLineWhenBlank="true" uuid="92b46a19-42c0-42f2-846a-3c7a7aaf0e2a"/>
<box padding="0">
<pen lineWidth="1.25" lineStyle="Solid" lineColor="#030303"/>
</box>
<textElement>
<paragraph lineSpacingSize="0.0"/>
</textElement>
<textFieldExpression><![CDATA[$F{text}]]></textFieldExpression>
</textField>
</band>
<band height="100">
<printWhenExpression><![CDATA[new Boolean($F{image}!=null)]]></printWhenExpression>
<image>
<reportElement x="0" y="0" width="190" height="100" uuid="1dc15e42-01a4-413f-b04e-30b8d0437e36"/>
<box>
<pen lineWidth="2.0" lineColor="#030303"/>
</box>
<imageExpression><![CDATA[$F{image}]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
The two solution will both render the result you are asking for, the are some difference with the page break, in the frame solution you can force the page break if both does not fit in page, while in the two band solution you will have a solution where band 1 can be on one page and band 2 on another.
The multiple detail band solution is also a bit cleaner to view in the design view, since in frame solution the image does appear to be outside of the band.

JSON DataAdapter using API causing slow report generation

I am having my API where I am sending a request from POSTMAN and it takes less than a second to respond. But, when I use the same API in JasperReport using JSON DataAdapter, it takes about 7 to 15 seconds to respond and generate the report. Here is a snapshot is taken after uploading the report to the server using Mozilla.
Here is the same report on the POSTMAN
It is not fetching anything from the API but just the login key. Here is a snapshot from the JasperStudio
Here is my jrxml
<?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_A4" language="javascript" pageWidth="595" pageHeight="200" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8fe94703-075f-4ae1-affc-bff8d7a8a4b8">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="POST_REQUEST_TO_GET_TOKEN"/>
<property name="ireport.jasperserver.url" value="http://server_address:port/jasperserver/"/>
<property name="ireport.jasperserver.user" value="user"/>
<property name="ireport.jasperserver.reportUnit" value="/Sub_Reports/test_A4"/>
<property name="ireport.jasperserver.report.resource" value="/Sub_Reports/test_A4_files/main_jrxml"/>
<property name="net.sf.jasperreports.data.adapter" value="POST_REQUEST_TO_GET_TOKEN.xml"/>
<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 language="JSON">
<![CDATA[]]>
</queryString>
<title>
<band height="59" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="555" height="59" uuid="691c8e97-8888-4786-9350-62d5f187820b"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="19" isBold="true" isItalic="false"/>
</textElement>
<textFieldExpression><![CDATA["This is a drill down sample report"]]></textFieldExpression>
</textField>
</band>
</title>
<summary>
<band height="75" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="555" height="50" uuid="4aba0c46-cda3-4611-97a2-1f446bd4f85b"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[It sends a POST request to an API and receives a token to put it into another POST request which will bring back the data from the API]]></text>
</staticText>
<textField>
<reportElement x="0" y="45" width="555" height="30" uuid="447eee49-5f57-4280-8f47-f5a5a8ff6503"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="16" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["This is in sub-reprots directory"]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>
I am unable to get the cause of many delays. Would anyone please help me figure this out? Thanks a lot.
I am using JasperSoft Studio 6.10 and JasperServer Version 7.

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.

Why an empty report is being created in 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>