日志
Java编程调用FOP转换
2011-06-12 12:50
2008-12-06 17:51 public boolean fop(String[] args) { boolean bRet = true; CommandLineOptions options = null; FOUserAgent foUserAgent = null; OutputStream out = null; try { options = new CommandLineOptions(); options.parse(args); foUserAgent = options.getFOUserAgent(); String outputFormat = options.getOutputFormat(); try { if (options.getOutputFile() != null) { out = new java.io.BufferedOutputStream( new java.io.FileOutputStream( options.getOutputFile())); foUserAgent.setOutputFile(options.getOutputFile()); } if (!MimeConstants.MIME_XSL_FO.equals(outputFormat)) { options.getInputHandler().renderTo(foUserAgent, outputFormat, out); } else { options.getInputHandler().transformTo(out); } } finally { IOUtils.closeQuietly(out); } } catch (Exception e) { if (options != null) { //options.getLogger().error("Exception", e); } if (options.getOutputFile() != null) { options.getOutputFile().delete(); } bRet = false; } return bRet; } |