0
BIRT 3.7 API를 사용하여 동적 PDF를 생성합니다. 우리는 아래의 로직을 사용하여 XML 데이터 소스 을 설정하고 있습니다. 아래의 스 니펫에서는 XML 문자열을 데이터 소스로 제공합니다. 이상하게도 지난 주부터 동적 데이터가 xml에서 채워지지 않습니다. FINEST 로그 수준에서도 예외가 발생하지 않습니다. 우리는 항아리를 업데이트하지 않았으므로이 기능을 중단시킨 변경 사항을 파악할 수 없습니다. 동적 값없이 PDF가 생성됩니다.XML 데이터 소스를 사용하여 동적 BIRT 보고서를 생성 할 때의 문제
자바에서 xml 데이터 소스를 birt 템플릿으로 설정하려고 시도 할만한 것이 있습니까?
String paramStr = readFileAsString(servletContext.getRealPath("/WEB-INF/classes")
+ "/resources/test.xml");
FileInputStream fis = new FileInputStream(servletContext.getRealPath("/WEB-INF/classes")
+ "/resources/BirtXmlDataTest.rptdesign");
IReportRunnable design = birtReportEngine.openReportDesign(fis);
DesignElementHandle designElementHandle = design.getDesignHandle();
ModuleHandle moduleHandle = designElementHandle.getModuleHandle();
ElementFactory designElementFactory = designElementHandle.getElementFactory();
OdaDataSourceHandle dataSourceHandle = designElementFactory.newOdaDataSource("Data Source",
"org.eclipse.birt.report.data.oda.xml");
moduleHandle.getDataSources().add(dataSourceHandle);
IRunAndRenderTask task = birtReportEngine
.createRunAndRenderTask(design);
PDFRenderOption options = new PDFRenderOption();
options.setSupportedImageFormats("JPG;PNG;BMP;SVG");
options.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_PDF);
options.setEmitterID(PDFRenderOption.OUTPUT_EMITTERID_PDF);
// options.setOutputStream(response.getOutputStream());
File file = new File("d:\\test" + File.separator + "file2.pdf");
FileOutputStream fos = new FileOutputStream(file);
// options.setOutputStream(response.getOutputStream());
options.setOutputStream(fos);
HashMap<String, Object> contextMap = new HashMap<String, Object>();
contextMap.put("org.eclipse.birt.report.data.oda.xml.inputStream",
new ByteArrayInputStream(paramStr.getBytes()));
contextMap.put(
"org.eclipse.birt.report.data.oda.xml.closeInputStream",
Boolean.TRUE);
task.setAppContext(contextMap);
task.setRenderOption(options);
task.run();
task.close();
XML 입력 스트림은 다음과 같이 컨텍스트 맵에 입력되는 문자열 "paramStr"에서 실제 읽기입니다. contextMap.put ("org.eclipse.birt.report.data.oda.xml.inputStream", 새 ByteArrayInputStream (paramStr.getBytes())); contextMap.put ( "org.eclipse.birt.report.data.oda.xml.closeInputStream", Boolean.TRUE); task.setAppContext (contextMap); 일주일 전에 실제로 잘 작동했습니다. –
아마도 코드에서 변경하지 않으면 문제는 xml 파일에 있어야합니다. 디버깅을하고 올바른 파일을 다시로드하는지 다시 확인 했습니까? –