# 1 楼答案 在JRPdfExporter的实例上,调用方法setParameter,并使用JRPdfExporterParameter中定义的常量来适当地设置版本 例如: exporter.setParameter(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_2); 版本1.2到1.7有一些常量 对于您的代码,解决方案如下: JasperPrint print = JasperFillManager.fillReport(jasperReport, param, con); File outputFile = new File("[Your destination filename goes here]"); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_FILE, outputFile); exporter.setParameter(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_2); exporter.exportReport(); 然后pdf将被写入outputFile,因此您不需要调用printReport
# 1 楼答案
在
JRPdfExporter
的实例上,调用方法setParameter
,并使用JRPdfExporterParameter
中定义的常量来适当地设置版本例如:
exporter.setParameter(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_2);
版本1.2到1.7有一些常量
对于您的代码,解决方案如下:
然后pdf将被写入
outputFile
,因此您不需要调用printReport