This document is to download jasper report with dynamic names from oracle apex.

Technology and Tool Used :

  • Oracle Apex
  • Jasper Reports
  • Javascripts
  • HTML

Use Case :

If a requirement arise from user to have jasper report with dynamic names, i.e every time when user download a pdf from apex application it gets downloaded in static name. With this code, we can download the report with dynamic names, for eg if the report is about invoice then we can download with invoice number as name.

Steps to be followed:

Step 1 : Create a page item in apex screen and pass the name of the pdf that you want to download.

Note : The item can be in hidden state also.

Step 2 : Create a static region and define a html block mentioned in the screenshot below and pass the item with document name as a parameter to the expression.

Note : In my case the name of the pdf is in P591_CYCLE_CODE item.

 

Step 3 : Enter the following code in HTML  Header Text. This code calls the jasper from the server and displays as pdf.

Step 4 : Now modify the jsp file in server and add the below mentioned code

response.setHeader( “Content-disposition”,”inline; filename=” + parameter10+”.pdf” );

                add the code before your exporter.exportReport(); line

!!Note in my case the parameter is 10 so I have mentioned parameter10 , parameter may vary based on your need!!

Step 5 Now save the .jsp  file and run your pdf again and click download, it will take the name of the parameter automatically.

Recent Posts

Start typing and press Enter to search