Compressing PDF from JasperReports

Questions and answers on developing, deploying and using plugins and JavaBeans

Compressing PDF from JasperReports

Postby stefbrt » Tue May 17, 2016 1:36 pm

I tried to compress the PDF File that I get from the JasperReports Plugin but it has always the same size.
Code: Select all
var reportParameters = new Object();
...
reportParameters["EXPORTER_PARAMETER:net.sf.jasperreports.engine.export.JRPdfExporterParameter.IS_COMPRESSED"] = "true";
...
var source = databaseManager.getDataSourceServerName(application.getActiveWindow().controller.getDataSource());
var tmpPDF = plugins.file.createTempFile('tempCorrespondence', '.pdf');
var pdfFile = plugins.jasperPluginRMI.runReport(source, 'Korrespondenzen.jasper', tmpPDF, plugins.jasperPluginRMI.OUTPUT_FORMAT.PDF, reportParameters, forms.BasConfiguration.configuration.defaultReportLocale);
correspondenceRecord.pdf = pdfFile;
databaseManager.saveData();


I tried it also with
Code: Select all
var reportParameters = new java.util.HashMap();
reportParameters.put('EXPORTER_PARAMETER:net.sf.jasperreports.engine.export.JRPdfExporterParameter.IS_COMPRESSED', "true");

but it has the same result.

I thought it was implemented in Version 4 of the JasperReports Plugin to set JR ExportParameters with this code.

Thanks for the help

Regards
Stefan
Stefan Brecht
7r ag, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
stefbrt
 
Posts: 152
Joined: Wed May 06, 2009 9:32 am
Location: Switzerland

Re: Compressing PDF from JasperReports

Postby mnaeimi » Mon May 23, 2016 1:03 pm

Hi Stefan,

1- It is important which version of jasperreport you are using. In newer versions JRPdfExporterParameter.IS_COMPRESSED is deprecated and replaced by PdfExporterConfiguration.isCompressed(). Please see here: http://jasperreports.sourceforge.net/ap ... meter.html

2- If you are using jasperreport plugin < v 5.0.0, following lines should work:

var reportParameters = new java.util.HashMap();
reportParameters.put('net.sf.jasperreports.engine.export.JRPdfExporterParameter.IS_COMPRESSED', "true")

Let me know if you need more help.

Regards,
Mina
Mina @ Servoy
mnaeimi
 
Posts: 12
Joined: Fri Jun 08, 2012 2:48 pm

Re: Compressing PDF from JasperReports

Postby stefbrt » Mon May 23, 2016 3:28 pm

Hi Mina

I am using the jasperreports version 5.6.1.
But how can i now use the PdfExporterConfiguration.isCompressed() in my servoy code?

I tried:
Code: Select all
reportParameters.put('PdfExporterConfiguration.isCompressed()', "true");

Code: Select all
reportParameters.put('net.sf.jasperreports.export.PdfExporterConfiguration.isCompressed()', "true");

Code: Select all
reportParameters.put('net.sf.jasperreports.export.PdfExporterConfiguration.isCompressed()', "");

Code: Select all
reportParameters.put('PdfExporterConfiguration.isCompressed()', "");


Regards,
Stefan
Stefan Brecht
7r ag, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
stefbrt
 
Posts: 152
Joined: Wed May 06, 2009 9:32 am
Location: Switzerland


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 3 guests

cron