Search code examples
exportjasper-reportsjasperserver

JasperReports - Specify Allowed Exporters


I would like to restrict the formats (e.g pdf only) which can be used to export a report created by iReport. Unfortunately I did not find out how to accomplish that. Is this even possible?

Thanks!


Solution

  • Yes, you can do it for JasperServer.
    You should edit viewReportBeans.xml config file (placed in %JASPER_SERVER_HOME%\apache-tomcat\webapps\jasperserver\WEB-INF\flows\ folder for my installation with bundled tomcat).

    The original block with export options:

    <util:map id="exporterConfigMap">
        <!-- comment/uncomment any of the lines below if you want related exporters 
             to be excluded/included in the viewer's exporters list -->
    
        <entry key="pdf" value-ref="pdfExporterConfiguration"/>
        <entry key="xls" value-ref="xlsExporterConfiguration"/>
        <entry key="csv" value-ref="csvExporterConfiguration"/>
        <entry key="docx" value-ref="docxExporterConfiguration"/>
        <entry key="rtf" value-ref="rtfExporterConfiguration"/>
        <entry key="swf" value-ref="swfExporterConfiguration"/>
        <entry key="odt" value-ref="odtExporterConfiguration"/>
        <entry key="ods" value-ref="odsExporterConfiguration"/>
        <entry key="xlsx" value-ref="xlsxExporterConfiguration"/>
        <!-- entry key="txt" value-ref="txtExporterConfiguration"/-->
    </util:map> 
    

    To allow only PDF export you can modify this block like this:

    <util:map id="exporterConfigMap">
        <entry key="pdf" value-ref="pdfExporterConfiguration"/>
    </util:map>