How to Call Reports in a Loop

I'm not 100% sure how to word this question, but basically what I'm trying to do is create a loop that can take a list of n number of items (in my case the parameters are barcode numbers) and pass those 1 by 1 as parameters to other reports in the Jasper Server, generating a PDF file for each one. For example, if I have 100 barcode numbers, I want to create 100 PDFs with a single REST call, and export them to a local folder. Is this possible?

matthew.kellar_1's picture
Joined: Jun 1 2018 - 11:25am
Last seen: 4 years 6 months ago

3 Answers:

I would suggest

create a jrxml with a subreport in it.

  • Main report should accept some arraylist as parameter
  • Group based on each arraylist value
  • in the group bands, create a subreport (which is your actual pdf layout)

when you make a rest call, send the parameter and generate multiple page pdf and 

then write some code to split multiple page pdf to single page pdf


reportdev's picture
Joined: Oct 12 2015 - 12:05pm
Last seen: 5 months 2 weeks ago

Simple answer, NO. A report is a single pdf file. If you want to generate multiple pdf files, you'll have to generate multiple reports.

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 5 months ago

Thank you for the responses. I ended up using a similar approach that reportdev suggested. Instead of using an ArrayList parameter, I just used a SQL query to find the parameter values I was looking for and passed those to a subreport in a report group to split them up. I couldn't get them all on separate PDFs though, they're all in one.

matthew.kellar's picture
Joined: Jan 18 2016 - 8:26am
Last seen: 9 months 4 weeks ago