XDocReport: XDocConverterException: не удается найти преобразователи из = DOCX

Я тестирую пример кода из XDocReport. И я объединил, создав отчет в формате docx и pdf на основе шаблона docx. Однако я продолжаю получать это сообщение

Apr 21, 2016 5:39:10 PM fr.opensagres.xdocreport.converter.ConverterRegistry internalFindConverter
SEVERE: Cannot find converters from=DOCX
fr.opensagres.xdocreport.converter.XDocConverterException: Cannot find converters from=DOCX
    at fr.opensagres.xdocreport.converter.ConverterRegistry.internalFindConverter(ConverterRegistry.java:121)
    at fr.opensagres.xdocreport.converter.ConverterRegistry.findConverter(ConverterRegistry.java:74)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.getConverter(AbstractXDocReport.java:667)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.convert(AbstractXDocReport.java:690)
    at fr.opensagres.xdocreport.samples.docxandfreemarker.DocxProjectWithFreemarkerList.main(DocxProjectWithFreemarkerList.java:231)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

Вот код:

try
        {
            InputStream in = DocxProjectWithFreemarker.class.getResourceAsStream( "DocxProjectWithFreemarkerList.docx" );
            IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Freemarker );

            FieldsMetadata metadata = report.createFieldsMetadata();

            metadata.load( "developers", Developer.class, true );

            IContext context = report.createContext();
            Project project = new Project( "XDocReport" );
            context.put( "project", project );

            List<Developer> developers = new ArrayList<Developer>();
            developers.add( new Developer( "ZERR", "Angelo", "[email protected]" ) );
            developers.add( new Developer( "Leclercq", "Pascal", "[email protected]" ) );

            context.put( "developers", developers );

            OutputStream out = new FileOutputStream( new File( "DocxProjectWithFreemarkerList_Out.docx" ) );
            report.process( context, out );

//            ===========================================================================================

            Options options = Options.getTo(ConverterTypeTo.PDF);

            OutputStream outt = new FileOutputStream(new File("DocxProjectWithFreemarkerList_Out.pdf"));
            report.convert(context, options, outt);

        }
        catch ( IOException e )
        {
            e.printStackTrace();
        }
        catch ( XDocReportException e )
        {
            e.printStackTrace();
        }

Что-то не так с кодом? Как я могу исправить эту ошибку?


person user3714598    schedule 21.04.2016    source источник
comment
Я не знаю продукта, но Cannot find converters from=DOCX кажется, что какой-то модуль может отсутствовать?   -  person Pekka    schedule 21.04.2016


Ответы (1)


Ваша проблема аналогична этой проблеме.

Вам необходимо иметь JAR-файлы fr.opensagres.xdocreport.converter.docx.xwpf и JAR-файлы ее зависимостей (iText и т. д.) в пути к классам.

person Angelo    schedule 22.04.2016