Jump to content
We've recently updated our Privacy Statement, available here ×

Problem with my report size


louis.gely

Recommended Posts

Hi!

 

I'm generating pdf reports with charts using JFreeChart 1.0.0 and JasperReports 1.2.1.

 

Before the application was generating the same reports using JasperReports 0.6 and JFreeChart 0.6.

 

Ancient report's size = 200ko

New report's size = 3Mo

 

Does someone have an explanation for this.

 

I tried every thing but nothing change...

 

What is the format for the charts' images? Is it different than in the old version of JasperReports?

 

For the information I'm generating my charts with scriptlet. An I would like to know if there was signigicant modification that could produce this huge size of report.

 

Thank you in advance.

Link to comment
Share on other sites

  • Replies 17
  • Created
  • Last Reply

Top Posters In This Topic

I read in the forum, that between JasperReports 0.6.8 and JasperReports 1.2.0 the pdf report that are generated are 3 times bigger (with image or charts). In my case, it's more than 10 time bigger, between 0.6.2 and 1.2.1 reports.

 

Weird?

Post edited by: louis.gely, at: 2006/09/01 11:46

Link to comment
Share on other sites

I am using now iText 1.3.1 and before it was iText 1.0.1.

 

Here some sample of the scriptlet for the pie chart :

 

Code:

public void afterDetailEval() throws JRScriptletException {
super.afterDetailEval();
PieDataset dataset = null;
try {
dataset = (PieDataset) JFreeDataSetFactory.getInstance().getDataSet(
JFreeDataSetFactory.DS_BUILDER_ENCOURS_ECHEANCE, this.getReportParameters());
} catch (ExceptionTechnique e) {
// TODO Auto-generated catch block
throw new JRScriptletException("Impossible de construire le DataSet pour l chart ["
+ JFreeDataSetFactory.DS_BUILDER_ENCOURS_ECHEANCE + "] Titre" + "["
+ EncoursParEcheanceChartReport.REPORT_DEFAULT_TITLE+ "]", e);
}
JFreeChart chart = ChartFactory.createPieChart3D(
EncoursParEcheanceChartReport.REPORT_DEFAULT_TITLE, dataset, true, true, false);
//Customization
ChartsUtils.configureStandard3DPiePlot((PiePlot3D) chart.getPlot());
ChartsUtils.configureStandardLegend((LegendTitle)chart.getLegend());
this.setVariableValue(EncoursParEcheanceChartReport.VAR_CHART_ENCOURS, new JCommonDrawableRenderer(chart));
}

 

The scriptlet for the timesseries chart :

 

Code:
[code]
public void afterDetailEval() throws JRScriptletException {
String libelleFonds = (String) this.getParameterValue(HistoVLParFondsReport.PRM_FONDS_NAME);
String fondsID = (String) this.getParameterValue(HistoVLParFondsReport.PRM_FONDS_ID);

if (fondsID != null) {
//Edition chart VL sur la période donnée
TimeSeriesCollection chartVLSeries = null;
Map reportParameters = getReportParameters();
try {
chartVLSeries = (TimeSeriesCollection) JFreeDataSetFactory.getInstance().getDataSet(
JFreeDataSetFactory.DS_BUILDER_HISTO_VL_PAR_FONDS, reportParameters);

} catch (ExceptionTechnique e) {
StringBuffer errorSgb = new StringBuffer();
String sep = System.getProperty("line.separator"«»);
String indent = "t";
errorSgb.append("HistoVLParFondsScriptlet.beforeReportInit :: "«»).append(sep).append(indent).append(
"Erreur en création de la Série histo des VL [" + e.getClass() + "]"«»).append(sep).append(indent)
.append("[" + e.getMessage() + "]"«»).append(sep).append(indent).append("FondsID[" + fondsID + "]"«»)
.append(sep).append(indent).append("FondsNom[" + libelleFonds + "]"«»).append(sep).append(indent).append(
"Une série vierge va être utilisée."«»);
LOG.error(errorSgb.toString(), e);
chartVLSeries = new TimeSeriesCollection(new TimeSeries(fondsID));
}

TimeSeries vlSeries = chartVLSeries.getSeries(fondsID);
vlSeries.setKey(libelleFonds);
//vlSeries.setName(libelleFonds);
double pourcent = 0;
if (vlSeries.getItemCount() > 0) {
pourcent = (vlSeries.getValue(vlSeries.getItemCount() - 1).doubleValue() - vlSeries.getValue(0)
.doubleValue())
/ Math.max(vlSeries.getValue(0).doubleValue(), 0.001);
}

JFreeChart chartVLSeriesAnnee = ChartFactory.createTimeSeriesChart(
libelleFonds + " - " + (String) reportParameters.get(ReportsPeriodiqueConstants.PRM_PERIODE_LABEL), "",
"en u20AC", chartVLSeries, false, false, false);

ChartsUtils.configureStandardXYPlot((XYPlot)chartVLSeriesAnnee.getPlot());
ChartsUtils.configureTitle(chartVLSeriesAnnee.getTitle());
this.setVariableValue(HistoVLParFondsReport.VAR_CHART_VL, new JCommonDrawableRenderer(chartVLSeriesAnnee));
this.setVariableValue(HistoVLParFondsReport.VAR_POURCENT_EVOL, new Double(pourcent));
}

Source of ChartsUtils :

Code:
[code]
/*
* Created on 12 oct. 2004
*
*/

import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.text.NumberFormat;

import org.jfree.chart.axis.AxisSpace;
import org.jfree.chart.labels.PieSectionLabelGenerator;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
import org.jfree.ui.RectangleInsets;
import org.jfree.util.Rotation;

/**
*
* Type ChartsUtils :
*
* @author dansou_d
* @version 1.0
*
*/
public final class ChartsUtils {
public static final Font FONT_ARIAL_8_PLAIN = new Font("Arial", Font.PLAIN, 8);
public static final Font TIMES_NEW_ROMAN_8_PLAIN = new Font("Times new roman", Font.PLAIN, 8);
public static final Font TIMES_NEW_ROMAN_5_PLAIN = new Font("Times new roman", Font.PLAIN, 5);
public static final String NO_DATA_MSG = "Aucune donnée à éditer";
/**
* Constructeur privé : Evite toute instanciation intempestive de cette classe
*
*/
private ChartsUtils() {
super();
}
public static final PieSectionLabelGenerator getLabelPercentileGenerator() {
return new StandardPieSectionLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat
.getPercentInstance());
}
public static final PieSectionLabelGenerator getPercentileGenerator() {
return new StandardPieSectionLabelGenerator("{2}", NumberFormat.getNumberInstance(), NumberFormat
.getPercentInstance());
}
/**
* Customization standard :
* <ul>
* <li>StartAngle = 180°
* <li>Direction = Sens aiguille montre
* <li>Label = Type pourcentage
* <li>NoDataMsg = Aucune donnée à éditer
* </ul>
* @param plot
*/
public static final void configureStandard3DPiePlot(PiePlot3D plot) {
plot.setStartAngle(180);
plot.setDirection(Rotation.CLOCKWISE);
plot.setLabelGenerator(getPercentileGenerator());
plot.setInteriorGap(0);

plot.setNoDataMessage(NO_DATA_MSG);
}
/**
* @param legend
*/
public static final void configureStandardLegend(LegendTitle legend) {
legend.setItemFont(TIMES_NEW_ROMAN_5_PLAIN);
}

/**
*
* @param plot : prm
*/
public static final void configureStandardXYPlot(XYPlot plot) {

// plot.setDataAreaRatio((double)1/3);
plot.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 1000F, Color.blue));
plot.getDomainAxis().setVerticalTickLabels(true);
plot.getDomainAxis().setTickLabelFont(TIMES_NEW_ROMAN_8_PLAIN);
plot.getRangeAxis().setTickLabelFont(TIMES_NEW_ROMAN_8_PLAIN);
// RectangleInsets insets = plot.getRangeAxis().getTickLabelInsets();
// insets.ZERO_INSETS;
plot.getRangeAxis().setTickLabelInsets(RectangleInsets.ZERO_INSETS);
plot.getRangeAxis().setLabelFont(TIMES_NEW_ROMAN_8_PLAIN);
AxisSpace as = new AxisSpace();
// as.setBottom(10);

as.setLeft(25);
// as.setRight(0);
// as.setTop(0);

plot.setFixedRangeAxisSpace(as);
plot.setNoDataMessage(NO_DATA_MSG);
}
/**
* @param legend
*/
public static final void configureTitle(TextTitle title) {
title.setFont(FONT_ARIAL_8_PLAIN);
}

}

 

Thank you, and if you need more code I'll reply fast.

 

Thanks again.

 

Maybe the .jrxml :

Code:
[code]
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
name="EncoursParEcheanceChart"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="595"
columnSpacing="0"
leftMargin="0"
rightMargin="0"
topMargin="0"
bottomMargin="0"
whenNoDataType="AllSectionsNoDetail"
scriptletClass="com.lds.noee.ent.noyau.reporting.synthesePeriodique.position.EncoursParEcheanceScriptlet"
isTitleNewPage="false"
isSummaryNewPage="false">
<property name="ireport.scriptlethandling" value="2" />
<property name="ireport.encoding" value="UTF-8" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />
<reportFont name="Detail_6" isDefault="false" fontName="Arial" size="6" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
<reportFont name="Header_6_Bold" isDefault="false" fontName="Arial" size="6" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
<reportFont name="Footer_6_Bold" isDefault="false" fontName="Arial" size="6" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
<reportFont name="Title_10_Bold" isDefault="false" fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
<reportFont name="BasPage_8_Italic" isDefault="false" fontName="Arial" size="8" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
<reportFont name="Detail_10" isDefault="false" fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
<reportFont name="Header_10_Bold" isDefault="false" fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1250" isPdfEmbedded="true"/>

<parameter name="prmIsSubReport" isForPrompting="false" class="java.lang.Boolean">
<parameterDescription><![CDATA[Dit si le template est exploité comme sub ou pas]]></parameterDescription>
<defaultValueExpression ><![CDATA[java.lang.Boolean.FALSE]]></defaultValueExpression>
</parameter>
<parameter name="prmReportTitle" isForPrompting="false" class="java.lang.String">
<parameterDescription><![CDATA[Le titre du report]]></parameterDescription>
</parameter>
<parameter name="prmEntNom" isForPrompting="false" class="java.lang.String"/>
<parameter name="prmEntCode" isForPrompting="false" class="java.lang.String"/>

<variable name="varChartEncours" class="net.sf.jasperreports.engine.JRRenderable" resetType="Report" calculation="System">
</variable>
<background>
<band height="0" isSplitAllowed="true" >
</band>
</background>
<title>
<band height="0" isSplitAllowed="true" >
</band>
</title>
<pageHeader>
<band height="0" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="0" isSplitAllowed="false" >
</band>
</columnHeader>
<detail>
<band height="405" isSplitAllowed="false" >
<image scaleImage="FillFrame" vAlign="Top" hAlign="Left" isUsingCache="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
mode="Opaque"
x="2"
y="5"
width="590"
height="400"
forecolor="#000000"
backcolor="#FFFFFF"
key="image-1"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid"
/>
<imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[$V{varChartEncours}]]></imageExpression>
</image>
</band>
</detail>
<columnFooter>
<band height="0" isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="0" isSplitAllowed="true" >
</band>
</pageFooter>
<summary>
<band height="0" isSplitAllowed="false" >
</band>
</summary>
</jasperReport>

Post edited by: louis.gely, at: 2006/09/04 12:59

Link to comment
Share on other sites

The increase in the PDF size seems to be related to chart texts/fonts. At some point between JR 0.6.6 and JR 0.6.7, a PdfContentByte.createGraphics call, used to retrieve Graphics2D instances on which SVG images were to be rendered, was replaced by PdfContentByte.createGraphicsShapes and this resulted in chart texts being rendered as shapes.

 

Not sure at this moment whether there are other changes (after JR 0.6.7) that affect this or what could be done to fix it.

 

Regards,

Lucian

Link to comment
Share on other sites

Temporarily, you could also revert the change by getting the JR sources and changing in JRPdfExporter.java this line

Code:
Graphics2D g = template.createGraphicsShapes(availableImageWidth, availableImageHeight);

to

Code:
[code]DefaultFontMapper mapper = new DefaultFontMapper();
Graphics2D g = template.createGraphics(availableImageWidth, availableImageHeight, mapper);

 

Regards,

Lucian

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...