作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在Eclipse上使用BIRT没问题,但是我的新公司使用IntelliJ IDEA。
在Gradle中使用项目
compile files('src/main/resources/lib/flute-1.3.jar')
compile(group: 'org.eclipse.birt.runtime', name: 'org.eclipse.birt.runtime', version: '4.4.2') { exclude(group: 'org.milyn', module: 'flute') }
shadowJar {
classifier = null
version = version
manifest {
attributes 'Main-Class': 'io.vertx.core.Starter'
attributes 'Main-Verticle': 'other.app.App'
}
mergeServiceFiles {
include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
}
}
IReportEngineFactory factory = (IReportEngineFactory) Platform .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
@Override
public void generateUserInformationPdf(JsonObject payload) {
try {
LOGGER.info("Starting render User Information");
/* begin get parameters */
CommonRequest request = gson.fromJson(payload, CommonRequest.class);
UserPdfPrint userInformation = gson.fromJson(request.getData(), UserPdfPrint.class);
String p_username = userInformation.getUsername();
String p_customername = userInformation.getCustomerName();
String p_dob = userInformation.getDob();
String p_license = userInformation.getLicense();
String p_licensedate = userInformation.getLicenseDate();
String p_licenseplace = userInformation.getLicensePlace();
String p_sex = userInformation.getSex();
String p_customerphone = userInformation.getCustomerPhone();
String p_email = userInformation.getEmail();
int p_licensetype = userInformation.getLicenseType();
/* end get parameters section */
/* load report design */
String reportName = config.getReportUserInformation();
IReportEngine engine = null;
IReportRunnable design = null;
URL url = null;
url = new URL(config.getReportFontConfig());
engineConfig = new EngineConfig();
engineConfig.setEngineHome("ReportEngine");
engineConfig.setLogConfig(null, Level.FINE);
engineConfig.setFontConfig(url);
Platform.startup(engineConfig);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(engineConfig);
design = engine
.openReportDesign(config.getReportTemplatePath()
+ "/" + reportName); // report
/* end load report design */
/* begin render report */
IRunAndRenderTask task = null;
PDFRenderOption renderContext = null;
HashMap contextMap = null;
task = engine.createRunAndRenderTask(design);
renderContext = new PDFRenderOption();
contextMap = new HashMap();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
renderContext);
contextMap.put("OdaJDBCDriverPassInConnection", config.getDbConnection());
task.setAppContext(contextMap);
task.setParameterValue("p_username", p_username);
task.setParameterValue("p_customername", p_customername);
task.setParameterValue("p_dob", p_dob);
task.setParameterValue("p_license", p_license);
task.setParameterValue("p_licensedate", p_licensedate);
task.setParameterValue("p_licenseplace", p_licenseplace);
task.setParameterValue("p_sex", p_sex);
task.setParameterValue("p_licensetype", String.valueOf(p_licensetype));
task.setParameterValue("p_email", p_email);
task.setParameterValue("p_customerphone", p_customerphone);
task.validateParameters();
String random = Generator.generateRandomNumber();
String today = DateTimes.getCurrentDate().toString();
String parsedToDate = DateTimes.parseDate(today, "EE MMM dd HH:mm:ss z yyyy").toString();
String toDateString = DateTimes.parseDate(parsedToDate, "dd-MM-yyyy-hh-mm-ss").toString();
String reportNameInFolder = "UserInformation" + toDateString
+ random;
String outPutFile = config.getReportOutputPath() + reportNameInFolder + ".pdf";
PDFRenderOption options = null;
options = new PDFRenderOption();
options.setOutputFormat("pdf");
options.setOutputFileName(outPutFile);
task.setRenderOption(options);
task.run();
System.out.println("All went well. Closing program!");
/* end render report */
engine.destroy();
task.close();
options.closeOutputStreamOnExit(true);
mqAdapter.pushToMQ(Transformers.toVertxJsonObject(new EnhancedSuccessResponse()
.setHeader(request.getHeader())
.setCodes(CodeResponse.SuccessCode.PRINT_PDF_REGISTER_SUCCESS.getCode())
.setData(gson.toJsonTree(new PdfReportResponse().setPdfLink(config.getReportOutputLink() + reportNameInFolder + ".pdf")))).encode(), QueueKeys.OtherQueue.ADMIN_GENERATE_USER_INFORMATION_PDF.getValue());
} catch (MalformedURLException e) {
LOGGER.error("Failed to get Font Config URL. {}", e.toString());
} catch (BirtException e1) {
LOGGER.error("Failed to start config. {}", e1.toString());
// e1.printStackTrace();
} catch (
Exception e) {
LOGGER.error("Failed to get design template. {}", e.toString());
System.err
.println("An error occured while running the report!");
LOGGER.error("An error occured while running the report! {}", e.toString());
// e.printStackTrace();
}
}
最佳答案
我也遇到过同样的问题。更新构建gradle并添加
"flute-1.3.jar" & "org.eclipse.orbit.mongodb-2.10.1.v20130422-1135.jar"
//Start of birt
compile(group: 'org.eclipse.birt.runtime', name: 'org.eclipse.birt.runtime', version: '4.4.2') {
exclude(group: 'org.milyn', module: 'flute')
exclude(group: 'org.eclipse.birt.runtime', module: 'org.eclipse.orbit.mongodb')
}
//End of birt
关于java - Birt报表-IReportEngineFactory为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52214609/
我是一名优秀的程序员,十分优秀!