
com.mntviews.jreport.JRExportPDF Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mnt-report Show documentation
Show all versions of mnt-report Show documentation
JasperReport server engine
package com.mntviews.jreport;
import com.mntviews.jreport.exception.JRExportException;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import net.sf.jasperreports.export.SimplePdfReportConfiguration;
import java.io.ByteArrayOutputStream;
public class JRExportPDF implements JRExportAction {
static final String EXTENSION = "pdf";
private static final String MIME_TYPE = "application/pdf";
@Override
public ByteArrayOutputStream export(JasperPrint jasperPrint, String configScript) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JRPdfExporter exporterPdf = new JRPdfExporter();
SimplePdfReportConfiguration configuration = new SimplePdfReportConfiguration();
exporterPdf.setConfiguration(configuration);
exporterPdf.setExporterInput(new SimpleExporterInput(jasperPrint));
exporterPdf.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream));
try {
exporterPdf.exportReport();
} catch (JRException e) {
throw new JRExportException(e);
}
return outputStream;
}
@Override
public String getExtension() {
return EXTENSION;
}
@Override
public String getMimeType() {
return MIME_TYPE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy