我正在尝试使用japser报告插件创建有关grails 3.3.1的PDF报告。
我按照此页面上的说明操作:https://puneetbehl.github.io/grails-jasper/docs/index.html#installation
但是当我下载PDF时,我总是收到一个空的pdf(或一个空的XML)。
的build.gradle
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.2.Final"
compile "org.hibernate:hibernate-ehcache:5.1.2.Final"
compile "org.grails.plugins:jasper:2.0.0.RC1"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.11.6"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}
index.gsp中的
<g:jasperReport
jasper="example_a4"
format="PDF,HTML,XML"
name="test">
</g:jasperReport>
example_a4.jrxml(在src / webapps / reports下):
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.3.final utlizzo versione della libreria JasperReports6.4.3 -->
<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="example_a4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="563f0f65-00af-4be9-84c2-f3c504b70afc">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement x="220" y="20" width="270" height="30" uuid="b4362a25-8b6d-4b9b-a743-56c5d90ba75e"/>
<text><![CDATA[ESEMPIO]]></text>
</staticText>
</band>
</title>
<pageFooter>
<band height="61" splitType="Stretch">
<staticText>
<reportElement x="250" y="30" width="100" height="30" uuid="eefc514b-4904-4cf1-bf5d-42df2137621f"/>
<text><![CDATA[PIE DI PAGINA]]></text>
</staticText>
</band>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
XML输出:
<?xml version="1.0" encoding="UTF-8"?>
<jasperPrint xmlns="http://jasperreports.sourceforge.net/jasperreports/print" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/print http://jasperreports.sourceforge.net/xsd/jasperprint.xsd" name="ddt" pageWidth="595" pageHeight="842" topMargin="20" leftMargin="20" bottomMargin="20" rightMargin="20" locale="it_IT" timezone="Europe/Rome">
<property name="net.sf.jasperreports.export.xml.start.page.index" value="0"/>
<property name="net.sf.jasperreports.export.xml.end.page.index" value="0"/>
<property name="net.sf.jasperreports.export.xml.page.count" value="1"/>
<origin band="background"/>
<origin band="title"/>
<origin band="pageHeader"/>
<origin band="columnHeader"/>
<origin band="detail"/>
<origin band="columnFooter"/>
<origin band="pageFooter"/>
<style name="Title" fontName="Arial" fontSize="26" isBold="true"/>
<style name="SubTitle" forecolor="#666666" fontName="Arial" fontSize="18"/>
<style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
<style name="Detail" fontName="Arial" fontSize="12"/>
<page/>
</jasperPrint>
我没有收到任何错误。