简体   繁体   中英

Jasper Print creation is very slow

I try to create a Jasper Print with an ResultSet to build an PDF Report with the print. The Problem is, that the creation of the Jasper Print is very slow. The ResultSet is a Table with about 5000 Rows. It takes more than 2 Minutes to create the Print.

I found this Solution: JasperReports fillReport too slow and resource consuming

But it does not work for me. The different is, that i use a dynamic report.

JasperPrint jasperPrint = DynamicJasperHelper.generateJasperPrint(dynamicReport, new ClassicLayoutManager(), resultSet);

EDIT: The critical Part is in the fillReport Method in the JRVerticalFiller class.

        if (this.next()) {
        this.fillReportStart();

        while(this.next()) {
            this.fillReportContent();
        }

        this.fillReportEnd();
    } 

the fillReportContent Method gets called again and again for almost two minutes.

I've never used Jasper Print, but if your goal is to create a PDF file containing all those 5000 results, why don't you create an html file containing all your results inside a <table><tr><td> elements and then use a tool like wkhtmltopdf in order to convert the file from html to pdf?

This way, it will take only a couple of seconds.

You can also specify a header and footer for every page of the pdf file (you can include an image or desired text etc.)

NOTE: wkhtmltopdf is not a java library, it's an executable that runs on most OS's however, you can use java's ProcessBuilder in order to execute it.

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