Running Jasper Report from Java code
- May 7, 2024
- 3 replies
- 2045 views
Version: Windchill 12.0
Use Case: We have a custom action where when the user clicks on it, a jasper report is downloaded as pdf in the background
Description:
Hello all,
I am trying to run a Jasper Report from java code. I have few questions regarding that-
1. I have a jrxml with multiple data sources( infoengine tasks), how do I combine all of them into one Jasper Print object using the below API?
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters);
2. When exporting the jasper report as pdf, how can I give the path so that the report gets automatically downloaded in the user's local system? Currently I am running the report on the server so the pdf is saved in the server location itself, so how can I change that? Below, instead of creating the LfDocumentReport.pdf in the particular location, it creates a pdf in appl/ptc/Windchill_12.0/Windchill location with the whole name given as path
JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\\Users\\55806@itcinfotech.com\\Downloads\\LfDocumentReport.pdf");
I have attached the code in this post. Any help or suggestions would be helpful
Thankyou,
Ramsha Kamal

