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.
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.
17 Answers:
Posted on September 1, 2006 at 11:44am
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
Weird?
Post edited by: louis.gely, at: 2006/09/01 11:46
Posted on September 4, 2006 at 12:58pm
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 :
Here some sample of the scriptlet for the pie chart :
Code: |
<br /> public void afterDetailEval() throws JRScriptletException {<br /> super.afterDetailEval();<br /> PieDataset dataset = null;<br /> try {<br /> dataset = (PieDataset) JFreeDataSetFactory.getInstance().getDataSet(<br /> JFreeDataSetFactory.DS_BUILDER_ENCOURS_ECHEANCE, this.getReportParameters());<br /> } catch (ExceptionTechnique e) {<br /> // TODO Auto-generated catch block<br /> throw new JRScriptletException("Impossible de construire le DataSet pour l chart ["<br /> + JFreeDataSetFactory.DS_BUILDER_ENCOURS_ECHEANCE + "] Titre" + "["<br /> + EncoursParEcheanceChartReport.REPORT_DEFAULT_TITLE+ "]", e);<br /> }<br /> JFreeChart chart = ChartFactory.createPieChart3D(<br /> EncoursParEcheanceChartReport.REPORT_DEFAULT_TITLE, dataset, true, true, false);<br /> //Customization<br /> ChartsUtils.configureStandard3DPiePlot((PiePlot3D) chart.getPlot());<br /> ChartsUtils.configureStandardLegend((LegendTitle)chart.getLegend());<br /> this.setVariableValue(EncoursParEcheanceChartReport.VAR_CHART_ENCOURS, new JCommonDrawableRenderer(chart));<br /> }</td></tr></tbody></table><br /> <br /> The scriptlet for the timesseries chart :<br /> <br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><br /> public void afterDetailEval() throws JRScriptletException {<br /> String libelleFonds = (String) this.getParameterValue(HistoVLParFondsReport.PRM_FONDS_NAME);<br /> String fondsID = (String) this.getParameterValue(HistoVLParFondsReport.PRM_FONDS_ID);<br /> <br /> if (fondsID != null) {<br /> //Edition chart VL sur la période donnée<br /> TimeSeriesCollection chartVLSeries = null;<br /> Map reportParameters = getReportParameters();<br /> try {<br /> chartVLSeries = (TimeSeriesCollection) JFreeDataSetFactory.getInstance().getDataSet(<br /> JFreeDataSetFactory.DS_BUILDER_HISTO_VL_PAR_FONDS, reportParameters);<br /> <br /> } catch (ExceptionTechnique e) {<br /> StringBuffer errorSgb = new StringBuffer();<br /> String sep = System.getProperty("line.separator"«»);<br /> String indent = "\t";<br /> errorSgb.append("HistoVLParFondsScriptlet.beforeReportInit :: "«»).append(sep).append(indent).append(<br /> "Erreur en création de la Série histo des VL [" + e.getClass() + "]"«»).append(sep).append(indent)<br /> .append("[" + e.getMessage() + "]"«»).append(sep).append(indent).append("FondsID[" + fondsID + "]"«»)<br /> .append(sep).append(indent).append("FondsNom[" + libelleFonds + "]"«»).append(sep).append(indent).append(<br /> "Une série vierge va être utilisée."«»);<br /> LOG.error(errorSgb.toString(), e);<br /> chartVLSeries = new TimeSeriesCollection(new TimeSeries(fondsID));<br /> }<br /> <br /> TimeSeries vlSeries = chartVLSeries.getSeries(fondsID);<br /> vlSeries.setKey(libelleFonds);<br /> //vlSeries.setName(libelleFonds);<br /> double pourcent = 0;<br /> if (vlSeries.getItemCount() > 0) {<br /> pourcent = (vlSeries.getValue(vlSeries.getItemCount() - 1).doubleValue() - vlSeries.getValue(0)<br /> .doubleValue())<br /> / Math.max(vlSeries.getValue(0).doubleValue(), 0.001);<br /> }<br /> <br /> JFreeChart chartVLSeriesAnnee = ChartFactory.createTimeSeriesChart(<br /> libelleFonds + " - " + (String) reportParameters.get(ReportsPeriodiqueConstants.PRM_PERIODE_LABEL), "",<br /> "en \u20AC", chartVLSeries, false, false, false);<br /> <br /> ChartsUtils.configureStandardXYPlot((XYPlot)chartVLSeriesAnnee.getPlot());<br /> ChartsUtils.configureTitle(chartVLSeriesAnnee.getTitle());<br /> this.setVariableValue(HistoVLParFondsReport.VAR_CHART_VL, new JCommonDrawableRenderer(chartVLSeriesAnnee));<br /> this.setVariableValue(HistoVLParFondsReport.VAR_POURCENT_EVOL, new Double(pourcent));<br /> }<br /> </td></tr></tbody></table><br /> Source of ChartsUtils : <br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><br /> /*<br /> * Created on 12 oct. 2004<br /> *<br /> */<br /> <br /> import java.awt.Color;<br /> import java.awt.Font;<br /> import java.awt.GradientPaint;<br /> import java.text.NumberFormat;<br /> <br /> import org.jfree.chart.axis.AxisSpace;<br /> import org.jfree.chart.labels.PieSectionLabelGenerator;<br /> import org.jfree.chart.labels.StandardPieSectionLabelGenerator;<br /> import org.jfree.chart.plot.PiePlot3D;<br /> import org.jfree.chart.plot.XYPlot;<br /> import org.jfree.chart.title.LegendTitle;<br /> import org.jfree.chart.title.TextTitle;<br /> import org.jfree.ui.RectangleInsets;<br /> import org.jfree.util.Rotation;<br /> <br /> /**<br /> * <br /> * Type ChartsUtils :<br /> * <br /> * @author dansou_d<br /> * @version 1.0<br /> * <br /> */<br /> public final class ChartsUtils {<br /> public static final Font FONT_ARIAL_8_PLAIN = new Font("Arial", Font.PLAIN, 8);<br /> public static final Font TIMES_NEW_ROMAN_8_PLAIN = new Font("Times new roman", Font.PLAIN, 8);<br /> public static final Font TIMES_NEW_ROMAN_5_PLAIN = new Font("Times new roman", Font.PLAIN, 5);<br /> public static final String NO_DATA_MSG = "Aucune donnée à éditer";<br /> /**<br /> * Constructeur privé : Evite toute instanciation intempestive de cette classe<br /> *<br /> */<br /> private ChartsUtils() {<br /> super();<br /> }<br /> public static final PieSectionLabelGenerator getLabelPercentileGenerator() {<br /> return new StandardPieSectionLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat<br /> .getPercentInstance());<br /> }<br /> public static final PieSectionLabelGenerator getPercentileGenerator() {<br /> return new StandardPieSectionLabelGenerator("{2}", NumberFormat.getNumberInstance(), NumberFormat<br /> .getPercentInstance());<br /> }<br /> /**<br /> * Customization standard : <br /> * <ul><br /> * <li>StartAngle = 180°<br /> * <li>Direction = Sens aiguille montre<br /> * <li>Label = Type pourcentage<br /> * <li>NoDataMsg = Aucune donnée à éditer<br /> * </ul><br /> * @param plot<br /> */<br /> public static final void configureStandard3DPiePlot(PiePlot3D plot) {<br /> plot.setStartAngle(180);<br /> plot.setDirection(Rotation.CLOCKWISE);<br /> plot.setLabelGenerator(getPercentileGenerator());<br /> plot.setInteriorGap(0);<br /> <br /> plot.setNoDataMessage(NO_DATA_MSG);<br /> }<br /> /**<br /> * @param legend<br /> */<br /> public static final void configureStandardLegend(LegendTitle legend) {<br /> legend.setItemFont(TIMES_NEW_ROMAN_5_PLAIN);<br /> }<br /> <br /> /**<br /> * <br /> * @param plot : prm<br /> */<br /> public static final void configureStandardXYPlot(XYPlot plot) {<br /> <br /> // plot.setDataAreaRatio((double)1/3);<br /> plot.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 1000F, Color.blue));<br /> plot.getDomainAxis().setVerticalTickLabels(true);<br /> plot.getDomainAxis().setTickLabelFont(TIMES_NEW_ROMAN_8_PLAIN);<br /> plot.getRangeAxis().setTickLabelFont(TIMES_NEW_ROMAN_8_PLAIN);<br /> // RectangleInsets insets = plot.getRangeAxis().getTickLabelInsets();<br /> // insets.ZERO_INSETS;<br /> plot.getRangeAxis().setTickLabelInsets(RectangleInsets.ZERO_INSETS);<br /> plot.getRangeAxis().setLabelFont(TIMES_NEW_ROMAN_8_PLAIN);<br /> AxisSpace as = new AxisSpace();<br /> // as.setBottom(10);<br /> <br /> as.setLeft(25);<br /> // as.setRight(0);<br /> // as.setTop(0);<br /> <br /> plot.setFixedRangeAxisSpace(as);<br /> plot.setNoDataMessage(NO_DATA_MSG);<br /> }<br /> /**<br /> * @param legend<br /> */<br /> public static final void configureTitle(TextTitle title) {<br /> title.setFont(FONT_ARIAL_8_PLAIN);<br /> }<br /> <br /> }</td></tr></tbody></table><br /> <br /> Thank you, and if you need more code I'll reply fast.<br /> <br /> Thanks again.<br /> <br /> Maybe the .jrxml :<br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><br /> <?xml version="1.0" encoding="UTF-8" ?><br /> <!-- Created with iReport - A designer for JasperReports --><br /> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"><br /> <jasperReport<br /> name="EncoursParEcheanceChart"<br /> columnCount="1"<br /> printOrder="Vertical"<br /> orientation="Portrait"<br /> pageWidth="595"<br /> pageHeight="842"<br /> columnWidth="595"<br /> columnSpacing="0"<br /> leftMargin="0"<br /> rightMargin="0"<br /> topMargin="0"<br /> bottomMargin="0"<br /> whenNoDataType="AllSectionsNoDetail"<br /> scriptletClass="com.lds.noee.ent.noyau.reporting.synthesePeriodique.position.EncoursParEcheanceScriptlet"<br /> isTitleNewPage="false"<br /> isSummaryNewPage="false"><br /> <property name="ireport.scriptlethandling" value="2" /><br /> <property name="ireport.encoding" value="UTF-8" /><br /> <import value="java.util.*" /><br /> <import value="net.sf.jasperreports.engine.*" /><br /> <import value="net.sf.jasperreports.engine.data.*" /><br /> <reportFont name="Detail_6" isDefault="false" fontName="Arial" size="6" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1250" isPdfEmbedded="true"/><br /> <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"/><br /> <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"/><br /> <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"/><br /> <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"/><br /> <reportFont name="Detail_10" isDefault="false" fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1250" isPdfEmbedded="true"/><br /> <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"/><br /> <br /> <parameter name="prmIsSubReport" isForPrompting="false" class="java.lang.Boolean"><br /> <parameterDescription><![CDATA[Dit si le template est exploité comme sub ou pas]]></parameterDescription><br /> <defaultValueExpression ><![CDATA[java.lang.Boolean.FALSE]]></defaultValueExpression><br /> </parameter><br /> <parameter name="prmReportTitle" isForPrompting="false" class="java.lang.String"><br /> <parameterDescription><![CDATA[Le titre du report]]></parameterDescription><br /> </parameter><br /> <parameter name="prmEntNom" isForPrompting="false" class="java.lang.String"/><br /> <parameter name="prmEntCode" isForPrompting="false" class="java.lang.String"/><br /> <br /> <variable name="varChartEncours" class="net.sf.jasperreports.engine.JRRenderable" resetType="Report" calculation="System"><br /> </variable><br /> <background><br /> <band height="0" isSplitAllowed="true" ><br /> </band><br /> </background><br /> <title><br /> <band height="0" isSplitAllowed="true" ><br /> </band><br /> </title><br /> <pageHeader><br /> <band height="0" isSplitAllowed="true" ><br /> </band><br /> </pageHeader><br /> <columnHeader><br /> <band height="0" isSplitAllowed="false" ><br /> </band><br /> </columnHeader><br /> <detail><br /> <band height="405" isSplitAllowed="false" ><br /> <image scaleImage="FillFrame" vAlign="Top" hAlign="Left" isUsingCache="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" ><br /> <reportElement<br /> mode="Opaque"<br /> x="2"<br /> y="5"<br /> width="590"<br /> height="400"<br /> forecolor="#000000"<br /> backcolor="#FFFFFF"<br /> key="image-1"<br /> stretchType="NoStretch"<br /> positionType="FixRelativeToTop"<br /> isPrintRepeatedValues="true"<br /> isRemoveLineWhenBlank="false"<br /> isPrintInFirstWholeBand="false"<br /> isPrintWhenDetailOverflows="false"/><br /> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/><br /> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" <br /> /><br /> <imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[$V{varChartEncours}]]></imageExpression><br /> </image><br /> </band><br /> </detail><br /> <columnFooter><br /> <band height="0" isSplitAllowed="true" ><br /> </band><br /> </columnFooter><br /> <pageFooter><br /> <band height="0" isSplitAllowed="true" ><br /> </band><br /> </pageFooter><br /> <summary><br /> <band height="0" isSplitAllowed="false" ><br /> </band><br /> </summary><br /> </jasperReport><br /> </td></tr></tbody></table><br>Post edited by: louis.gely, at: 2006/09/04 12:59 |
Posted on September 5, 2006 at 2:51pm
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
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
Posted on September 5, 2006 at 3:16pm
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);</td></tr></tbody></table><br /> to<br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre>DefaultFontMapper mapper = new DefaultFontMapper();<br /> Graphics2D g = template.createGraphics(availableImageWidth, availableImageHeight, mapper);<br /> </td></tr></tbody></table><br /> <br /> Regards,<br /> Lucian |
Posted on September 6, 2006 at 9:47am
I couldn't tell at the moment, we need to investigate this more. I think it would be better to post a bug ([url=http://jasperforge.org/sf/tracker/do/listArtifacts/projects.jasperreport...) so that we can track this properly.
Regards,
Lucian
Regards,
Lucian