How to Call Reports in a Loop

0

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: 1 year 1 month ago

3 Answers:

1

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
1226
Joined: Oct 12 2015 - 12:05pm
Last seen: 2 months 3 weeks ago
0

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
45129
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 month 1 week ago
0

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: 5 months 3 weeks ago
Feedback