aradicev Posted June 26 Share Posted June 26 Hi, I'm using community edition of Jaspersoft Studio and have created a very simple template which I am using in my Spring boot application. When I try to create the report, the application breaks with the exception net.sf.jasperreports.engine.JRRuntimeException: Missing JasperReports PDF Extension (jasperreports-pdf-x.x.x.jar) when calling the method JasperExportManager.exportReportToPdf. Can someone tell me what am I doing wrong? ma jrxml file: <!-- Created with Jaspersoft Studio version 7.0.0.final using JasperReports Library version 7.0.0-b478feaa9aab4375eba71de77b4ca138ad2f62aa --> <jasperReport name="machine" language="java" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5342457c-ca3c-448c-8044-41f83ffc1ed0"> <parameter name="brandLogo" class="java.io.InputStream"/> <parameter name="machineName" class="java.lang.String"/> <query language="sql"><![CDATA[]]></query> <background splitType="Stretch"/> <title height="264" splitType="Stretch"> <element kind="image" uuid="7bc2d9b0-a3d5-46bf-b07f-d0ec01e5d051" x="10" y="10" width="80" height="20" linkType="None" linkTarget="Self"> <expression><![CDATA[$P{brandLogo}]]></expression> <property name="com.jaspersoft.studio.unit.width" value="px"/> </element> <element kind="textField" uuid="92ea5b34-3219-43b6-bcc1-21ccf15f1065" x="10" y="30" width="80" height="30" fontSize="12.0" vTextAlign="Middle"> <expression><![CDATA[$P{machineName}]]></expression> <property name="com.jaspersoft.studio.unit.height" value="px"/> </element> <element kind="frame" uuid="c6e7b692-9163-4148-901f-60bb3fff3e9f" x="10" y="64" width="270" height="200"/> </title> <pageHeader height="35" splitType="Stretch"/> <columnHeader height="61" splitType="Stretch"/> <detail> <band height="125" splitType="Stretch"/> </detail> <columnFooter height="45" splitType="Stretch"/> <pageFooter height="54" splitType="Stretch"/> <summary height="42" splitType="Stretch"/> </jasperReport> my service for pdf creation: @Service public class JasperReportService { private static final Logger log = LoggerFactory.getLogger(JasperReportService.class); public byte[] fetchMachineReport(MachinesInfo machinesInfo) throws Exception { JasperReport jasperReport; try { jasperReport = (JasperReport) JRLoader.loadObject(ResourceUtils.getFile("machine.jrxml")); } catch (FileNotFoundException | JRException e) { try { File file = ResourceUtils.getFile("classpath:machine.jrxml"); jasperReport = JasperCompileManager.compileReport(file.getAbsolutePath()); JRSaver.saveObject(jasperReport, "machine.jasper"); } catch (FileNotFoundException | JRException e1) { log.error(e1.getLocalizedMessage()); e.printStackTrace(); throw new Exception("System error!"); } } // JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(machinesInfo.machineList()); Map<String, Object> parametersMap = new HashMap<>(); JasperPrint jasperPrint = null; byte[] pdfReport = null; InputStream brandLogoInputStream = new ByteArrayInputStream(machinesInfo.machineList().get(0).machinePicture()); parametersMap.put("brandLogo", brandLogoInputStream); parametersMap.put("machineName", machinesInfo.machineList().get(0).machineModel()); try { jasperPrint = JasperFillManager.fillReport(jasperReport, parametersMap, new JREmptyDataSource()); pdfReport = JasperExportManager.exportReportToPdf(jasperPrint); } catch (JRException | JRRuntimeException e) { log.error(e.getLocalizedMessage()); e.printStackTrace(); throw new Exception("System error!"); } return pdfReport; } } 1 Link to comment Share on other sites More sharing options...
lucianc Posted June 29 Share Posted June 29 You need to add a dependency to jasperreports-pdf 7.0.0 in your project, see at https://central.sonatype.com/artifact/net.sf.jasperreports/jasperreports-pdf/overview Regards, Lucian Link to comment Share on other sites More sharing options...
aradicev Posted July 10 Author Share Posted July 10 On 6/29/2024 at 4:53 PM, lucianc said: You need to add a dependency to jasperreports-pdf 7.0.0 in your project, see at https://central.sonatype.com/artifact/net.sf.jasperreports/jasperreports-pdf/overview Regards, Lucian Hi Lucian, thank you for you answer but that's exactly what I have done and I got this exception. As I said, after I have added the dependency to the version 6.20.6 I got rid of this exception. regards Andrija Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now