iagotomas Posted September 8, 2010 Share Posted September 8, 2010 Hi all, we're using JasperServer 3.7 under linux and we'd like to encrypt the generated PDF's we were trying to find a way to set the pdf encryption permissions in a global way, such as other encryption properties that may be set in jasperreports.properties , I understand that it's possible using jasperreports library just by setting the appropiate JrPdfExporterParameter (see Permissions) to the permissions we want to set, but is there a way through JasperServer or we have to stay with an unprintable PDF when it's encrypted. Thanks Link to comment Share on other sites More sharing options...
iagotomas Posted September 21, 2010 Author Share Posted September 21, 2010 We've finally managed to change pdf export permissions, we had to change com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl method exportToPdf and change js.spring.properties in order to make it work.We've tried to change com.jaspersoft.jasperserver.war.action.ReportPdfExporter but it only affected when generating the report through the web interface and it didn't make any effect on reports generated through web service we also tried to change com.jaspersoft.jasperserver.ws.axis2.PdfWSExporter without success too. Finally we did it changing the method exportToPdf as attached to this post and changing the bean.class.engineService property from js.spring.properties.Hope this may help someone.Code:public void exportToPdf(ExecutionContext context, String reportUnitURI, Map exportParameters) { ReportUnit reportUnit = (ReportUnit) getRepositoryResource(context, reportUnitURI); setThreadRepositoryContext(context, null, reportUnitURI); try { OrigContextClassLoader origContext = setContextClassLoader(context, reportUnit, false); try { exportParameters.put(JRExporterParameter.URL_HANDLER_FACTORY, RepositoryURLHandlerFactory.getInstance()); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameters(exportParameters); exporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE); exporter.setParameter(JRPdfExporterParameter.PERMISSIONS,new Integer(PdfWriter.AllowPrinting)); exporter.exportReport(); } finally { revert(origContext); } } catch(JRException e) { log.error("Error while exporting report to PDF", e); throw new JSExceptionWrapper(e); } finally { resetThreadRepositoryContext(); } } 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