IDEMPIERE-311 JasperReport: Loading pdf font from classpath is not working

This commit is contained in:
Heng Sin Low 2012-06-20 15:50:54 +08:00
parent 9d5f9f291b
commit f66d47695a
1 changed files with 6 additions and 2 deletions

View File

@ -8,11 +8,11 @@ import java.util.logging.Level;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import net.sf.jasperreports.engine.JRExporterParameter; import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRCsvExporter; import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.engine.export.JRHtmlExporter; import net.sf.jasperreports.engine.export.JRHtmlExporter;
import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter; import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.JRXlsExporterParameter; import net.sf.jasperreports.engine.export.JRXlsExporterParameter;
@ -149,7 +149,11 @@ public class ZkJRViewer extends Window implements EventListener, ITabOnCloseHand
log.log(Level.FINE, "Path="+path + " Prefix="+prefix); log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
} }
File file = File.createTempFile(prefix, ".pdf", new File(path)); File file = File.createTempFile(prefix, ".pdf", new File(path));
JasperExportManager.exportReportToPdfFile(jasperPrint, file.getAbsolutePath()); JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, file.getAbsolutePath());
exporter.setParameter(JRExporterParameter.CLASS_LOADER, exporter.getClass().getClassLoader());
exporter.exportReport();
media = new AMedia(getTitle(), "pdf", "application/pdf", file, true); media = new AMedia(getTitle(), "pdf", "application/pdf", file, true);