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

rnarala

Members
  • Posts

    13
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by rnarala

  1. Yes, I did that too. It did not help. Looks like the image the chart is getting converted as PNG type image and that occupies more space. regards, Ravi
  2. Hello, I have a report with charts (data loaded from a database field) in the detail section. I created a PDF report. The size of this pdf is 7.17 MB for 30 pages. The increase number of charts increases the PDF size. Is there a way to curb the size of the PDF? I set the PDF compression too with the following code. That did not help. Code: JRPdfExporter exporter = new JRPdfExporter(); exporter .setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.setParameter(JRExporterParameter.FONT_MAP, fontMap); exporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE); exporter.setParameter(JRPdfExporterParameter.IS_128_BIT_KEY, Boolean.TRUE); exporter.setParameter(JRPdfExporterParameter.PERMISSIONS, new Integer(PdfWriter.AllowPrinting)); exporter.setParameter(JRPdfExporterParameter.IS_COMPRESSED, Boolean.TRUE); exporter.exportReport(); regards, Ravi
  3. Hi, I have a report template that gets data from a Bean Collection Data Source. I am generating a PDF from this. When no data the I do not want generate any pages. Is this possible. If so how and if not why? regards, Ravi
  4. Hello, I have a Main report that contains 2 sub reports(SummaryReport, DetailReport). My requirement is to insert a blank report template(i.e a blank page) at the end of the first report when the first report ends in a odd numbered page. Is there a way to include sub reports dynamically based on a condition. regards, Ravi Narala
  5. Hi Shannon, Thanks for the info. Yes I have an image embedded in the PDF. I will try to do something to compress it. Can you think of any third party API's for PDF compression. regards, Ravi
  6. Hello, I've generated a PDF report that is 8 MB size for 29 pages. Looks like it is not compressed. After going thru the forums I came to know that I need to set the compression. Even after setting the compresion the PDF size is very big. Given below is my code snippet Code: JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.setParameter(JRExporterParameter.FONT_MAP, fontMap); exporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE); exporter.setParameter(JRPdfExporterParameter.IS_128_BIT_KEY, Boolean.TRUE); exporter.setParameter(JRPdfExporterParameter.PERMISSIONS, new Integer(PdfWriter.AllowPrinting)); exporter.setParameter(JRPdfExporterParameter.IS_COMPRESSED, Boolean.TRUE); exporter.exportReport(); I would like to know if I am missing something. regards, Ravi
  7. even the italics does not work. I tried it with <i>This is a italics text<i> it rendered a plain text
  8. it is html content <h1>This is a header text</h1>
  9. Hello, I went thru the forums to fing how to get the HTML markup work in PDF. I read that setting the markup="styled" in jrxml would fix it . But it did not fix it. Given below is my jrxml snippet Code: <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="15" y="388" width="555" height="62" backcolor="#C0C0C0" key="textField" positionType="Float"/> <box></box> <textElement markup="styled"> <font size="12"/> </textElement> <textFieldExpression class="java.lang.String"> <![CDATA[$F{heading}]]></textFieldExpression> </textField> And I followed the MarkUp example in my java code. Given below is my Java code Code:[code] public class ReportServlet extends BaseServlet { /** * */ private static final long serialVersionUID = 1L; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // URI - WebContext/rpt/{templateName}/{treeName}/{timePeriodId}/... ? // or parameters? String qs[] = request.getRequestURI().split("/"«»); String templateName = "/MainReport.jasper"; String treeName = "datatree"; int timePeriodId = 0; if (qs.length == 6) { // TODO: FIX THIS templateName = "/" + qs[3] + ".jasper"; treeName = qs[4]; timePeriodId = Integer.parseInt(qs[5]); } UserSession session = UserSession.login(request, "rnarala", "rnd26575", "de"«»); ServletOutputStream sos = null; try { byte[] bArray = GenerateReport(timePeriodId, session, treeName, templateName); response.setContentLength(bArray.length); response.setHeader("Content-Disposition", "inline; filename=report.pdf"«»); response.setContentType("application/pdf"«»); sos = response.getOutputStream(); sos.write(bArray); sos.flush(); } catch (Exception re) { re.printStackTrace(); response.getOutputStream().println(re.getMessage()); } finally { try { if (sos != null) { sos.flush(); sos.close(); } } catch (Exception e1) { e1.printStackTrace(); } } } /** * @param timePeriodId * The id of time period. * @param session * The user session that is required to build the ReportTree * @param treeName * The data tree name. * @param templateName * The JasperReport template name. * @return PDF byte array The byte array of the generated PDF */ public byte[] GenerateReport(int timePeriodId, UserSession session, String treeName, String templateName) { InputStream is = null; ByteArrayOutputStream baos = null; try { baos = new ByteArrayOutputStream(); String r = getClass().getResource("/MainReport.jrxml"«»).getPath(); File reports = new File(r.substring(0, r.lastIndexOf('/'))); for (File f : reports.listFiles()) { if (f.getName().endsWith("jrxml"«»)) { System.err.println(f); JasperCompileManager.compileReportToFile(f.getPath(), f .getPath().replaceFirst("jrxml", "jasper"«»)); } } ReportTree tree = session.getReportTree(timePeriodId, treeName); List<ReportTreeNode> rootList = new ArrayList<ReportTreeNode>(); rootList.add(tree.root); JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource( rootList, true); is = this.getClass().getResourceAsStream(templateName); JasperPrint jasperPrint = JasperFillManager.fillReport(is, new HashMap<Object, Object>(), ds); JRPdfExporter exporter = new JRPdfExporter(); Map<Object, Object> fontMap = new HashMap<Object, Object>(); fontMap.put(new FontKey("Arial", true, false), new PdfFont( "Helvetica-Bold", "Cp1252", false)); fontMap.put(new FontKey("Arial", false, true), new PdfFont( "Helvetica-Oblique", "Cp1252", false)); fontMap.put(new FontKey("Arial", true, true), new PdfFont( "Helvetica-BoldOblique", "Cp1252", false)); fontMap.put(new FontKey("Comic Sans MS", false, false), new PdfFont("COMICBD.TTF", "Cp1252", true)); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.setParameter(JRExporterParameter.FONT_MAP, fontMap); exporter.exportReport(); } catch (JRException jre) { jre.printStackTrace(); throw new RuntimeException( "Exception Filling the template with data", jre); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("Exception in GenerateReport", e); } finally { try { if (is != null) { is.close(); } } catch (Exception e1) { e1.printStackTrace(); } } return baos.toByteArray(); } } please let me know if I am missing something. ANy help in this regard is appreciated. regards, Ravi
  10. Hello, I am using JRBeanCollectionDataSource to populate jasper reports. How do I propagate the data source parameter from master report to sub report to sub report.What would be datasource expression for that Also I would like to know how to write a data source expression to access a property of a JRBeanCollectionDataSource. regards, RNarala
  11. Hi Shan, Geven below is my Sub report jrxml 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="SubReport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="535" pageHeight="802" columnWidth="535" columnSpacing="0" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenNoDataType="AllSectionsNoDetail" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <style name="GreenFont" isDefault="false" forecolor="#00CC00" > </style> <parameter name="SRDS" isForPrompting="false" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <field name="name" class="java.lang.String"/> <field name="id" class="java.lang.String"/> <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="11" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="57" isSplitAllowed="true" > <staticText> <reportElement style="GreenFont" x="307" y="3" width="43" height="18" key="staticText-3"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement> <font/> </textElement> <text><![CDATA[NAME:]]></text> </staticText> <staticText> <reportElement style="GreenFont" x="167" y="3" width="24" height="18" key="staticText-4"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement> <font/> </textElement> <text><![CDATA[iD:]]></text> </staticText> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement style="GreenFont" x="355" y="3" width="100" height="18" key="textField"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement style="GreenFont" x="200" y="3" width="100" height="18" key="textField"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{id}]]></textFieldExpression> </textField> <staticText> <reportElement style="GreenFont" x="7" y="0" width="127" height="15" key="staticText-5"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement> <font/> </textElement> <text><![CDATA[Detail Band in SubReport]]></text> </staticText> <subreport isUsingCache="true"> <reportElement x="7" y="25" width="522" height="26" key="subreport-1"/> <dataSourceExpression><![CDATA[$P{SRDS}]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA["/SSReport.jasper"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary> </jasperReport>
  12. We have a problem where the JRBeanCollectionDataSource does not propagate to sub-sub-report in spite of passing the data source to Main report. We were able to get data to sub report level. We have a report tree that has 2 members, data and children where children - is a Collection of ReportTreeNode i.e a DynaBean data - is a Map that contains the children We have 3 levels of tree structure where the root node ------> Main report | sub node ------> sub report | sub sub node ------> sub-sub report The problem is when we supply a Collection to JRBeanCollectionDataSource, the data for the sub-sub-report is not getting populated. It always searches for the property of the sub-sub-report at the sub-report level and fails with an unknown property exception. Given below is the code snippet. We have created a Data Source parameter "SRDS" in our report templates and refer to that as a data source expression in our sub reports. Given below is the code snippet. Code: ReportTree rTree = session.getReportTree(timePeriodId, treeName); ReportTreeNode root = rTree.root; // root.children contains collection of DynaBeans // root.data is a map that contains the list of children to iterate over. Children may contain list of Children. // Add data to JASPER Template from the tree JRBeanCollectionDataSource records = new JRBeanCollectionDataSource(root.children); InputStream inputStream = this.getClass().getResourceAsStream("/TestReport.jasper"«»); Map<String, Object> masterMap = new HashMap<String, Object>(); masterMap.putAll(root.data); // datasource expression from report templates added to map masterMap.put("SRDS", records); JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, masterMap, new JREmptyDataSource()); JasperExportManager.exportReportToPdf(jasperPrint); Can anyone shed some light on this and let me know if I am missing something. regards, RNarala
  13. Hello, We are creating nested sub reports that take JRBeanCollectionDataSource as data source. The data source seems to be visible to sub report but not to the report isnide the sub report. We added fields in the nested sub report that corresponds to the property in the bean. While executing the report it came back with a unknown property exception on the bean. We ran it in in debugger we were able to see the property and values. For us it seems like Bean Data Source is not visible to last report. Any help/ideas in this regard in greatly appreciated. thanks, Ravi
×
×
  • Create New...