Grails 2.3.7 - Jasper reports pdf / excel empty

0

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

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.")
}


In my index.gsp file i have,

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

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

%PDF-1.4
 
%âãÏÓ
 
1 0 obj
 
<</Length 29/Filter/FlateDecode>>stream
 
xœ+är
 
á26S°00SIár
 
á
 
äâ 13-
 
endstream
 
endobj
 
3 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]>>
 
endobj
 
2 0 obj
 
<</ITXT(2.1.7)/Type/Pages/Count 1/Kids[3 0 R]>>
 
endobj
 
4 0 obj
 
<</Type/Catalog/ViewerPreferences<</PrintScaling/AppDefault>>/Pages 2 0 R>>
 
endobj
 
5 0 obj
 
<</Creator(JasperReports \(report name\))/Producer(iText 2.1.7 by 1T3XT)/ModDate(D:20140425165259-05'00')/CreationDate(D:20140425165259-05'00')>>
 
endobj
 
xref
 
0 6
 
0000000000 65535 f
 
0000000015 00000 n
 
0000000326 00000 n
 
0000000110 00000 n
 
0000000389 00000 n
 
0000000480 00000 n
 
trailer
 
<</Root 4 0 R/ID [<5ff4d9752fefdbe898e3b7311f196e7e><31c6a083d568eac2c6c2f5cdd3ce6db5>]/Info 5 0 R/Size 6>>
 
startxref
 
641
 
%%EOF

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>

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.

dsrini.open's picture
Joined: Apr 21 2014 - 2:45pm
Last seen: 5 years 7 months ago

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 ?

dsrini.open - 5 years 9 months ago

0 Answers:

No answers yet
Feedback