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

Grails 2.3.7 - Jasper reports pdf / excel empty


dsrini.open

Recommended Posts

I am trying to mirror the grails report generation blog,  (but in grails 2.3.7 / jasper plugin 1.8.0)- http://ironicprogrammer.blogspot.com/2009/09/creating-jasper-reports-in-grails.html

In the my BookController.groovy file i have -

def createReport = {    def books = Book.list(params)    log.debug(books.toString())    chain(controller:'jasper',action:'index',model:[data:books],params:params)    log.debug("File printed successfully.")}[/code]


In my index.gsp file i have,
 

<g:jasperReport controller="book" action="createReport" inline="true" jasper="books.jrxml" format="PDF" name="All Books" > [/code]

 

I am always getting a blank PDF though the content looks different -
 

%PDF-1.4%âãÏÓ1 0 obj<</Length 29/Filter/FlateDecode>>streamxœ+ärá26S°00SIáráäâ 13-endstreamendobj3 0 obj<</Group<</Type/Group/CS/DeviceRGB/S/Transparency>>/Parent 2 0 R/Contents 1 0 R/Type/Page/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/ColorSpace<</CS/DeviceRGB>>>>/MediaBox[0 0 595 842]>>endobj2 0 obj<</ITXT(2.1.7)/Type/Pages/Count 1/Kids[3 0 R]>>endobj4 0 obj<</Type/Catalog/ViewerPreferences<</PrintScaling/AppDefault>>/Pages 2 0 R>>endobj5 0 obj<</Creator(JasperReports (report name))/Producer(iText 2.1.7 by 1T3XT)/ModDate(D:20140425165259-05'00')/CreationDate(D:20140425165259-05'00')>>endobjxref0 60000000000 65535 f0000000015 00000 n0000000326 00000 n0000000110 00000 n0000000389 00000 n0000000480 00000 ntrailer<</Root 4 0 R/ID [<5ff4d9752fefdbe898e3b7311f196e7e><31c6a083d568eac2c6c2f5cdd3ce6db5>]/Info 5 0 R/Size 6>>startxref641%%EOF[/code]

The books.jrxml looks like this -

<?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="report name"     pageWidth="595"     pageHeight="842"     columnWidth="535"     leftMargin="20"     rightMargin="20"     topMargin="20"     bottomMargin="20">    <property name="ireport.scriptlethandling" value="0"/>    <property name="ireport.encoding" value="UTF-8"/>    <import value="net.sf.jasperreports.engine.*"/>    <import value="java.util.*"/>    <import value="net.sf.jasperreports.engine.data.*"/>    <style name="pagetitle" isDefault="false" fontName="SansSerif" fontSize="14"/>    <field name="title" class="java.lang.String"/>    <field name="author" class="java.lang.String"/>    <field name="publisher" class="java.lang.String"/>    <field name="category" class="java.lang.String"/>    <background>        <band/>    </background>    <title>        <band height="79">            <staticText>                <reportElement style="pagetitle" x="0" y="0" width="201" height="46"/>                <text>Some text <![CDATA[books]]></text>            </staticText>            <break>                <reportElement x="0" y="29" width="100" height="1" uuid="71e38fc6-6790-4cae-9951-d10d4b81e6cd"/>            </break>        </band>    </title>    <pageHeader>        <band height="35"/>    </pageHeader>    <columnHeader>        <band height="61">            <staticText>                <reportElement key="staticText" x="0" y="39" width="100" height="20"/>                <text><![CDATA[$P{name}.toString()]]></text>            </staticText>            <staticText>                <reportElement key="staticText" x="0" y="39" width="100" height="20"/>                <text><![CDATA[Title]]></text>            </staticText>            <staticText>                <reportElement key="staticText" x="130" y="39" width="100" height="20"/>                <text><![CDATA[Author]]></text>            </staticText>            <staticText>                <reportElement key="staticText" x="266" y="39" width="100" height="20"/>                <text><![CDATA[Publisher]]></text>            </staticText>            <staticText>                <reportElement key="staticText" x="396" y="39" width="100" height="20"/>                <text><![CDATA[Category]]></text>            </staticText>        </band>    </columnHeader>    <detail>        <band height="42">            <textField isBlankWhenNull="false" hyperlinkType="None">                <reportElement key="textField" x="0" y="15" width="130" height="20"/>                <textElement/>                <textFieldExpression class="java.lang.String"><![CDATA[$F{title}]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="false" hyperlinkType="None">                <reportElement key="textField" x="130" y="15" width="136" height="20"/>                <textElement/>                <textFieldExpression class="java.lang.String"><![CDATA[$F{author}]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="false" hyperlinkType="None">                <reportElement key="textField" x="266" y="15" width="130" height="20"/>                <textElement/>                <textFieldExpression class="java.lang.String"><![CDATA[$F{publisher}]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="false" hyperlinkType="None">                <reportElement key="textField" x="396" y="15" width="147" height="20"/>                <textElement/>                <textFieldExpression class="java.lang.String"><![CDATA[$F{category}]]></textFieldExpression>            </textField>        </band>    </detail>    <columnFooter>        <band height="45"/>    </columnFooter>    <pageFooter>        <band height="54"/>    </pageFooter>    <summary>        <band height="42"/>    </summary></jasperReport>[/code]

I tried by placing both books.jrxml/ books.jasper / both in the web-app/reports directory. Any idea on what's going on ?

Everything looks the same as in the blog, except the pdf / xls / html report generation is not happening properly.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I am getting the same kind of pdf for demo in jasperDemo/demo -

under sample-list-domain-classes

That tells there is something wrong in the report Generation, and not with my controller / my jrxml report definition. Might be the plugin's not working as part of 1.8.0 version ?

Link to comment
Share on other sites

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...