Код: Выделить всё
Options options = Options.getFrom(DocumentKind.ODT).to(ConverterTypeTo.PDF);
InputStream raw = this.getResources().openRawResource(R.raw.timesheet_template);
IXDocReport xdocGenerator = XDocReportRegistry.getRegistry().loadReport(raw, TemplateEngineKind.Freemarker);
IContext context = xdocGenerator.createContext();
IConverter converter = ConverterRegistry.getRegistry().getConverter(options);
OutputStream out = new FileOutputStream(HOME_PATH+"/test.pdf");
xdocGenerator.convert(context, options, out);
raw.close();
out.close();
< /code>
ошибка: < /p>
fr.opensagres.xdocreport.core.XDocReportException: Null template engine. Set template engine with IXDocReport#setTemplateEngine.
< /code>
Другой метод: < /p>
Options options = Options.getFrom(DocumentKind.ODT).to(ConverterTypeTo.PDF);
IConverter converter = ConverterRegistry.getRegistry().getConverter(options);
InputStream raw = this.getResources().openRawResource(R.raw.timesheet_template);
OutputStream out = new FileOutputStream(HOME_PATH+"/test.pdf");
converter.convert(raw, out, options);
raw.close();
out.close();
< /code>
ошибка: < /p>
java.lang.NullPointerException: Attempt to invoke interface method 'void fr.opensagres.xdocreport.converter.IConverter.convert(java.io.InputStream, java.io.OutputStream, fr.opensagres.xdocreport.converter.Options)' on a null object reference
< /code>
от чтения онлайн и сами ошибок, я считаю, что существует основная зависимость, которая не доступна по умолчанию в Android. Я не знаю, что это такое или как его включить. У них есть знак воды, поэтому я хочу использовать Xdocreport. < /P>
Я импортирую следующее в Gradle: < /p>
implementation 'fr.opensagres.xdocreport:fr.opensagres.xdocreport.document.odt:2.1.0'
< /code>
Любая помощь будет оценена.implementation 'fr.opensagres.xdocreport:fr.opensagres.xdocreport.document.odt:2.1.0'
implementation 'fr.opensagres.xdocreport:fr.opensagres.xdocreport.template.freemarker:2.1.0'
implementation 'fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter.odt.odfdom:2.1.0'
implementation 'ro.andob.androidawt:androidawt:1.0.4'
Код: Выделить всё
configurations {
all { // You should exclude one of them not both of them
exclude group: "com.sun.activation", module: "jakarta.activation"
}
}
Код: Выделить всё
maven { url "https://andob.io/repository/open_source" }
-dontwarn java.lang.invoke.**
< /code>
Код такой же, как и в вопросе. Эта настройка решит проблему дубликата класса, добавьте конвертер для Xdocreport для использования и добавления зависимостей java.awt.
Подробнее здесь: https://stackoverflow.com/questions/796 ... xdocreport
Мобильная версия