0

Java で XDocReport ライブラリを使用して、odt テンプレートを使用して odt ドキュメントを作成し、そのファイルを pdf ファイルに変換したいと考えています。コードを実行するたびにエラーが発生しました:

 Error in fr.opensagres.xdocreport.document.AbstractXDocReport, line 866: fr.opensagres.xdocreport.core.XDocReportException: Null template engine. Set template engine with IXDocReport#setTemplateEngine

私はこれを試しました:

public void convertToPDF(DominoDocument document) {             
        if (document != null) {
            try {
                String ooFileName = "C:\\WINDOWS\\Temp\\odtFolder\\PrintFree.odt";                  

                InputStream is = new FileInputStream(ooFileName);
                IXDocReport report;
                report = XDocReportRegistry.getRegistry().loadReport(is,TemplateEngineKind.Velocity);
                IContext context = report.createContext();              
                context.put("Body", "HelloWorld");

                OutputStream out = new FileOutputStream(new File( "C:\\WINDOWS\\Temp\\odtFolder\\PrintFree"+System.nanoTime()+".pdf"));
                Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.ODFDOM); 
                report.process(context,options,out);
                System.out.println("Success");


            } catch (XDocReportException e) {
                System.out.println("XDocException");
                OpenLogItem.logError(e); 
            } 
}
4

1 に答える 1

0

Velocity を使用したいようですので、 Velocity で ITemplateEngine の実装を提供するfr.opensagres.xdocreport.template.velocity JAR をクラスパスに追加する必要があります。Velocity JAR とその依存関係も必要です。

于 2015-11-04T15:15:02.843 に答える