0
넷빈즈 응용 프로그램에서 BIRT PDF 파일을 생성하고내가 이클립스 이클립스 BIRT 플러그인으로 보고서를 만들었습니다
내가 문서를 둘러 보았다 한 콘솔 응용 프로그램 (나는이를 만들 넷빈즈를 사용)에서 PDF를 만들려면 그러나 나는 정말로 일할 것이 아무것도 없다. .rptdesign에서 PDF를 생성하려면 BIRT를 어떻게 호출 할 수 있습니까?
넷빈즈 응용 프로그램에서 BIRT PDF 파일을 생성하고내가 이클립스 이클립스 BIRT 플러그인으로 보고서를 만들었습니다
내가 문서를 둘러 보았다 한 콘솔 응용 프로그램 (나는이를 만들 넷빈즈를 사용)에서 PDF를 만들려면 그러나 나는 정말로 일할 것이 아무것도 없다. .rptdesign에서 PDF를 생성하려면 BIRT를 어떻게 호출 할 수 있습니까?
이클립스 사이트에서이 코드의 대부분을 얻었지만 지금은 찾을 수없는 것 같습니다. 아래에 구현 코드를 주석 처리했지만 나머지는 사용할 수 있어야합니다. 모든 가져 오기는 정상적으로 실행됩니다. 아래의 printReport
방법은 보고서 URL에서 PDF를 생성합니다.
import java.io.ByteArrayOutputStream;
import java.util.Collection;
import java.util.Iterator;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IGetParameterDefinitionTask;
import org.eclipse.birt.report.engine.api.IParameterDefnBase;
import org.eclipse.birt.report.engine.api.IParameterGroupDefn;
import org.eclipse.birt.report.engine.api.IParameterSelectionChoice;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.IScalarParameterDefn;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
public class BirtEngine {
IReportEngine engine = null;
EngineConfig config = null;
public BirtEngine()
{
try {
config = new EngineConfig();
config.setBIRTHome("C:\\birtruntime\\ReportEngine");
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
}catch(Exception e){
e.printStackTrace();
}
}
public void openReport(String report)
{
try {
IReportRunnable design = null;
design = engine.openReportDesign(report);
}catch(Exception ex){
ex.printStackTrace();
}
}
public void renderReport(String report)
{
try {
IReportRunnable design = null;
design = engine.openReportDesign(report);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
HTMLRenderOption options = new HTMLRenderOption();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
options.setOutputStream(bos);
options.setOutputFormat("html");
options.setEmbeddable(true);
task.setRenderOption(options);
task.run();
task.close();
//TreeBirtFrameView.jEditorPane1.setContentType("text/html");
//TreeBirtFrameView.jEditorPane1.setText(bos.toString());
}catch(Exception ex){
ex.printStackTrace();
}
}
public void printReport(String report)
{
try {
IReportRunnable design = null;
design = engine.openReportDesign(report);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
PDFRenderOption options = new PDFRenderOption();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
options.setOutputStream(bos);
options.setOutputFormat("pdf");
task.setRenderOption(options);
task.run();
task.close();
//Runtime.getRuntime().exec("\\\\myServer\\pgms$\\Adobe\\Reader 9.0\\Reader\\acrord32.exe report.pdf");
}catch(Exception ex){
ex.printStackTrace();
}
}
public void stopPlatform()
{
engine.destroy();
Platform.shutdown();
}
}