2

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.

pmueller
  • 143
  • 1
  • 19
  • Did you use Java profiler? Did you try to debug? – Alex K Jun 22 '20 at 16:18
  • The fillReport Method in the JRVerticalFiller Class takes so much time. First i thought, its an invinity loop. But it takes so much time to create ReportContent. – pmueller Jun 23 '20 at 08:28

1 Answers1

-1

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.

Sergio
  • 658
  • 1
  • 9
  • 22
  • may I ask why the down vote? if your goal is to create a PDF containing 5000 rows from your Resultset, this is a workaround, and it takes less than 2 seconds (instead of 2 minutes) which from my point of view, is a better solution. – Sergio Jul 10 '20 at 05:03