简体   繁体   中英

Experiences with Jasper Reports producing word format and PDF

I want to create a document (such as a invoice) with jasper reports in both MS Word and PDF format. Is it possible to generate both from the same jrxml report definition?

As MS Word support starts with DOCX format and lacks of support for DOC the comparision is between MS Word DOCX format and PDF.

Could this be done with jasper without headache? What are your experiences with this approach? What about fonts, layouts, page breaks, images? Will Jasper produce similar results with MS Word and PDF?

Regards, Stefan

JasperReport is a reporting engine in which you create reporting template and fill in this template with the values from either data source or from the Database. Once this template is filled with the data, JasperReport provides many export option for exporting the generated report in desired format of the file.

The supported format from what I know are pdf/excel/html. * For .p *df , JasperReport uses iText library while for excel generation it uses POI library . These libraries are standard libraries and can be used as a standalone library also in order to create Pdf or Excel.

As far as formatting of the report is concerned, I would advise you to create the reporting template and the actual report in the iReport and fix the layout issues if any from ireport. Then you can export the .jrxml file from iReport into your project and fill it with Data. This will take care of the formatting.

As is the case with .pdf file, it retains most of the formatting as will be observed in the iReport. With excel the formatting tends to break but the API provides useful function using which the formatting in excel can also be done at ease.

A point to note however would be that as iText and POI both are external libraries, somewhere or the other there would be a very slight mismatch in the formatting of the actual report but then you can tweak it to appear it proper with some trials.

My personal experience on Windows and Linux suggests that first identify the target machine on which your application is expected to run. Design your reporting layout then according to the operating system. This is needed because at time the actual report generated on Windows and Linux differ a bit in formatting and this generally happens due to Fonts.

Some things, I learned since my question:

The support for DOCX+XLSX improved since may '13. The first tests produced quit poor results, bug things got better since then.

Get the download jasperreports-zzz-project.tar.gz and have a look at the demos . I found them useful. They gave me more insight, that the information on the G00gle.

regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM