PDA

View Full Version : Blank pdf with jasperreports


Sarah80
Jun 9th, 2008, 10:20 AM
Hi!,
I have a problem. I am using jasperreports+ hibernate + spring. I have created a file *.jasper with ireports and I used it from java with spring, but my pdf is blank and I haven't errors and my pdf must be a stupid text like "Hello world". What happens?

EagleEye666666
Jun 13th, 2008, 06:10 AM
empty Datasource for filling the PDF.

you need to change whenNoDataType property

<jasperReport name="YourReport" ... whenNoDataType="AllSectionsNoDetail" ....>

that it's printing all section just no detail.

that's all..

dfloch
Jun 16th, 2008, 06:02 AM
To print the detail section, you can use this kind of controller

public class PdfController extends AbstractController {
protected final Log logger = LogFactory.getLog(getClass());
protected ModelAndView handleRequestInternal(
HttpServletRequest request,
HttpServletResponse response) throws Exception {

Map<String,Object> model = new HashMap<String,Object>();
model.put("myDatasource", new JREmptyDataSource());

return new ModelAndView("simpleReport", model);
}
}

and add the following lines to views.properties file :

simpleReport.class=org.springframework.web.servlet .view.jasperreports.JasperReportsPdfView
simpleReport.url=/reports/simple.jrxml
simpleReport.reportDataKey=myDatasource

dr_pompeii
Jun 16th, 2008, 08:59 AM
but my pdf is blank and I haven't errors and my pdf must be a stupid text like "Hello world". What happens?
the text is already written in the report or you send the text how a parameter?

post some code, it be useful

the other answers are valid too

regards