在birt報告生成期間,我正在低於excpetion。下面給出堆棧跟蹤代碼。使用birt引擎生成報告時的FontHandler異常
我需要在我的應用程序中添加任何其他字體相關的文件嗎? 有沒有人有這方面的想法。
當我把選項渲染爲'HTML'時,它工作正常。只有當我把渲染選項設置爲'pdf'時纔會拋出異常。
BirtEngineDesktop.java:import java.io.File; import java.io.FileInputStream; import java.util.HashMap; import java.util.logging.Level;導入 org.eclipse.birt.core.exception.BirtException;導入 org.eclipse.birt.core.framework.Platform;導入 org.eclipse.birt.report.engine.api。*;
公共類BirtEngineDesktop {
public static void main(String[] args) throws Exception { String reportName = "new_report_2.rptdesign"; IReportEngine engine = null; IReportRunnable design = null; IRunAndRenderTask task = null; PDFRenderOption renderContext = null; HashMap contextMap = null; PDFRenderOption options = null; final EngineConfig conf = new EngineConfig(); conf.setEngineHome("ReportEngine"); System.out.println("BIRT_HOME: " + conf.getBIRTHome()); conf.setLogConfig(null, Level.FINE); try { Platform.startup(conf); } catch (BirtException e1) { e1.printStackTrace(); } IReportEngineFactory factory = (IReportEngineFactory) Platform .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY); engine = factory.createReportEngine(conf); try { design = engine.openReportDesign(reportName); } catch (Exception e) { System.err.println("An error occured during the opening of the report file!"); e.printStackTrace(); System.exit(-1); } task = engine.createRunAndRenderTask(design); renderContext = new PDFRenderOption(); contextMap = new HashMap(); FileInputStream fis = new FileInputStream(new File("C:\\test\\sample.xml")); contextMap.put("org.eclipse.datatools.enablement.oda.xml.inputStream",fis); contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT, renderContext); task.setAppContext(contextMap); options = new PDFRenderOption(); options.setOutputFileName("D://"+reportName + ".pdf"); options.setOutputFormat("pdf"); task.setRenderOption(options); try { task.run(); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } engine.destroy(); System.exit(0); } }
我的堆棧跟蹤是:
org.eclipse.birt.report.engine.api.impl.EngineTask handleFatalExceptions
SEVERE: An error happened while running the report. Cause:
java.lang.NullPointerException
at org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.getMappedFont(FontHandler.java:201)
at org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.selectFont(FontHandler.java:167)
at org.eclipse.birt.report.engine.layout.pdf.font.FontSplitter.buildChunk(FontSplitter.java:98)
at org.eclipse.birt.report.engine.layout.pdf.font.FontSplitter.getNext(FontSplitter.java:189)
at org.eclipse.birt.report.engine.layout.pdf.text.ChunkGenerator.getNext(ChunkGenerator.java:104)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextCompositor.getNextTextArea(TextCompositor.java:189)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextCompositor.getNextArea(TextCompositor.java:127)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextAreaLayout.layoutChildren(TextAreaLayout.java:182)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextAreaLayout.layout(TextAreaLayout.java:173)
at org.eclipse.birt.report.engine.nLayout.area.impl.InlineTextArea.layout(InlineTextArea.java:65)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.startContent(LayoutEngine.java:561)
at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startText(ContentEmitterAdapter.java:147)
at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startLabel(ContentEmitterAdapter.java:153)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:65)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.visitContent(LayoutEngine.java:716)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.visitContent(LayoutEngine.java:724)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.startForeign(LayoutEngine.java:767)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:77)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.visitContent(LayoutEngine.java:716)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.visitChildren(LayoutEngine.java:740)
at org.eclipse.birt.report.engine.nLayout.RegionLayoutEngine.layout(RegionLayoutEngine.java:31)
at org.eclipse.birt.report.engine.nLayout.area.impl.PageArea.layoutFooter(PageArea.java:489)
at org.eclipse.birt.report.engine.nLayout.area.impl.PageArea.initialize(PageArea.java:249)
at org.eclipse.birt.report.engine.nLayout.area.impl.RootArea.createNewPage(RootArea.java:147)
at org.eclipse.birt.report.engine.nLayout.area.impl.RootArea.initialize(RootArea.java:138)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.setContainer(LayoutEngine.java:368)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine._startContainer(LayoutEngine.java:456)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.startContainer(LayoutEngine.java:355)
at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startPage(ContentEmitterAdapter.java:65)
at org.eclipse.birt.report.engine.emitter.CompositeContentEmitter.startPage(CompositeContentEmitter.java:290)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:47)
at org.eclipse.birt.report.engine.layout.html.buffer.PageNode.start(PageNode.java:49)
at org.eclipse.birt.report.engine.layout.html.buffer.ContainerBufferNode.start(ContainerBufferNode.java:79)
at org.eclipse.birt.report.engine.layout.html.buffer.ContainerBufferNode.start(ContainerBufferNode.java:79)
at org.eclipse.birt.report.engine.layout.html.buffer.ContainerBufferNode.start(ContainerBufferNode.java:79)
at org.eclipse.birt.report.engine.layout.html.buffer.ContainerBufferNode.start(ContainerBufferNode.java:79)
at org.eclipse.birt.report.engine.layout.html.buffer.HTMLPageBuffer.startContent(HTMLPageBuffer.java:113)
at org.eclipse.birt.report.engine.layout.html.buffer.TableBreakBuffer.startContent(TableBreakBuffer.java:287)
at org.eclipse.birt.report.engine.layout.html.HTMLLeafItemLM.start(HTMLLeafItemLM.java:67)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:139)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.resumeLayout(HTMLInlineStackingLM.java:111)
at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.layoutNodes(HTMLInlineStackingLM.java:160)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLTableBandLM.layoutChildren(HTMLTableBandLM.java:67)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLTableLM.layoutChildren(HTMLTableLM.java:132)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:181)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at BirtEngineDesktop.main(BirtEngineDesktop.java:69)
An error occured while running the report!
org.eclipse.birt.report.engine.api.EngineException: Error happened while running the report.
at org.eclipse.birt.report.engine.api.impl.EngineTask.handleFatalExceptions(EngineTask.java:2329)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:191)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at BirtEngineDesktop.main(BirtEngineDesktop.java:69)
Caused by: java.lang.NullPointerException
at org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.getMappedFont(FontHandler.java:201)
at org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.selectFont(FontHandler.java:167)
at org.eclipse.birt.report.engine.layout.pdf.font.FontSplitter.buildChunk(FontSplitter.java:98)
at org.eclipse.birt.report.engine.layout.pdf.font.FontSplitter.getNext(FontSplitter.java:189)
at org.eclipse.birt.report.engine.layout.pdf.text.ChunkGenerator.getNext(ChunkGenerator.java:104)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextCompositor.getNextTextArea(TextCompositor.java:189)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextCompositor.getNextArea(TextCompositor.java:127)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextAreaLayout.layoutChildren(TextAreaLayout.java:182)
at org.eclipse.birt.report.engine.nLayout.area.impl.TextAreaLayout.layout(TextAreaLayout.java:173)
at org.eclipse.birt.report.engine.nLayout.area.impl.InlineTextArea.layout(InlineTextArea.java:65)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.startContent(LayoutEngine.java:561)
at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startText(ContentEmitterAdapter.java:147)
at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startLabel(ContentEmitterAdapter.java:153)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:65)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.visitContent(LayoutEngine.java:716)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.visitContent(LayoutEngine.java:724)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.startForeign(LayoutEngine.java:767)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:77)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.visitContent(LayoutEngine.java:716)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.visitChildren(LayoutEngine.java:740)
at org.eclipse.birt.report.engine.nLayout.RegionLayoutEngine.layout(RegionLayoutEngine.java:31)
at org.eclipse.birt.report.engine.nLayout.area.impl.PageArea.layoutFooter(PageArea.java:489)
at org.eclipse.birt.report.engine.nLayout.area.impl.PageArea.initialize(PageArea.java:249)
at org.eclipse.birt.report.engine.nLayout.area.impl.RootArea.createNewPage(RootArea.java:147)
at org.eclipse.birt.report.engine.nLayout.area.impl.RootArea.initialize(RootArea.java:138)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.setContainer(LayoutEngine.java:368)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine._startContainer(LayoutEngine.java:456)
at org.eclipse.birt.report.engine.nLayout.LayoutEngine.startContainer(LayoutEngine.java:355)
at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startPage(ContentEmitterAdapter.java:65)
at org.eclipse.birt.report.engine.emitter.CompositeContentEmitter.startPage(CompositeContentEmitter.java:290)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:47)
at org.eclipse.birt.report.engine.layout.html.buffer.PageNode.start(PageNode.java:49)
at org.eclipse.birt.report.engine.layout.html.buffer.ContainerBufferNode.start(ContainerBufferNode.java:79)
at org.eclipse.birt.report.engine.layout.html.buffer.ContainerBufferNode.start(ContainerBufferNode.java:79)
at org.eclipse.birt.report.engine.layout.html.buffer.ContainerBufferNode.start(ContainerBufferNode.java:79)
at org.eclipse.birt.report.engine.layout.html.buffer.ContainerBufferNode.start(ContainerBufferNode.java:79)
at org.eclipse.birt.report.engine.layout.html.buffer.HTMLPageBuffer.startContent(HTMLPageBuffer.java:113)
at org.eclipse.birt.report.engine.layout.html.buffer.TableBreakBuffer.startContent(TableBreakBuffer.java:287)
at org.eclipse.birt.report.engine.layout.html.HTMLLeafItemLM.start(HTMLLeafItemLM.java:67)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:139)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.resumeLayout(HTMLInlineStackingLM.java:111)
at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.layoutNodes(HTMLInlineStackingLM.java:160)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLTableBandLM.layoutChildren(HTMLTableBandLM.java:67)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLTableLM.layoutChildren(HTMLTableLM.java:132)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:181)
... 2 more
嘗試過的選項,但力量的工作! – hemanth