Stack Exchange
loading odt file (document template) using freemarker. how to generate odt file to pdf
getting this exception :  
fr.opensagres.xdocreport.core.XDocReportException: java.lang.NoSuchMethodError: freemarker.template.Configuration.setTagSyntax(I)V
  at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:151)
  at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:83)
  at fr.opensagres.xdocreport.document.AbstractXDocReport.processTemplateEngine(AbstractXDocReport.java:775)
  at fr.opensagres.xdocreport.document.AbstractXDocReport.convert(AbstractXDocReport.java:703)
  at com.altruista.mp.dao.ContactSyncImpl$1.processRow(ContactSyncImpl.java:231)
  at org.springframework.jdbc.core.JdbcTemplate$RowCallbackHandlerResultSetExtractor.extractData(JdbcTemplate.java:1607)
  at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:708)
  at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:752)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:762)
  at com.altruista.mp.dao.ContactSyncImpl.applyRemoteChanges(ContactSyncImpl.java:128)
  at com.altruista.mp.sync.SyncController.run(SyncController.java:137)
  at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:634)
  at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:652)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:909)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:898)
  at com.altruista.mp.sync.Application.main(Application.java:19)
Caused by: java.lang.NoSuchMethodError: freemarker.template.Configuration.setTagSyntax(I)V
  at fr.opensagres.xdocreport.template.freemarker.FreemarkerTemplateEngine.setFreemarkerConfiguration(FreemarkerTemplateEngine.java:184)
  at fr.opensagres.xdocreport.template.freemarker.FreemarkerTemplateEngine.getDefaultConfiguration(FreemarkerTemplateEngine.java:256)
  at fr.opensagres.xdocreport.template.freemarker.FreemarkerTemplateEngine.getFreemarkerConfiguration(FreemarkerTemplateEngine.java:174)
  at fr.opensagres.xdocreport.template.freemarker.FreemarkerTemplateEngine.processWithCache(FreemarkerTemplateEngine.java:110)
  at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:111)
  ... 19 more
CONTACT: Couchbase [7207d5b6-cea2-48ee-8464-bc73ce21aa5f] <= SQL [ 582375 ]
java.io.FileNotFoundException: Template fr.opensagres.xdocreport.document.odt.ODTReport@fbe57c!content.xml not found.
  at freemarker.template.Configuration.getTemplate(Configuration.java:441)
  at freemarker.template.Configuration.getTemplate(Configuration.java:404)
  at fr.opensagres.xdocreport.template.freemarker.FreemarkerTemplateEngine.processWithCache(FreemarkerTemplateEngine.java:110)
  at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:111)
  at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:83)
  at fr.opensagres.xdocreport.document.AbstractXDocReport.processTemplateEngine(AbstractXDocReport.java:775)
  at fr.opensagres.xdocreport.document.AbstractXDocReport.convert(AbstractXDocReport.java:703)
  at com.altruista.mp.dao.ContactSyncImpl$1.processRow(ContactSyncImpl.java:231)
  at org.springframework.jdbc.core.JdbcTemplate$RowCallbackHandlerResultSetExtractor.extractData(JdbcTemplate.java:1607)
  at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:708)
  at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:752)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:762)
  at com.altruista.mp.dao.ContactSyncImpl.applyRemoteChanges(ContactSyncImpl.java:128)
  at com.altruista.mp.sync.SyncController.run(SyncController.java:137)
  at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:634)
  at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:652)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:909)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:898)
  at com.altruista.mp.sync.Application.main(Application.java:19)

using these depencdecies: 
<dependency>
  <groupId>commons-fileupload</groupId>
  <artifactId>commons-fileupload</artifactId>
  <version>1.2.1</version>
  <optional>true</optional>
</dependency>
<dependency>
    <groupId>fr.opensagres.xdocreport</groupId>
    <artifactId>fr.opensagres.xdocreport.template.freemarker</artifactId>
    <version>1.0.4</version>
    </dependency>
<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.core</artifactId>
  <version>1.0.4</version>
</dependency>
<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.converter</artifactId>
  <version>1.0.4</version>
</dependency>
<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.template</artifactId>
  <version>1.0.4</version>
</dependency>
<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.document</artifactId>
  <version>1.0.4</version>
</dependency>
<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.document.docx</artifactId>
  <version>1.0.4</version>
    </dependency>
    <dependency>
    <groupId>fr.opensagres.xdocreport</groupId>
    <artifactId>fr.opensagres.xdocreport.document.odt</artifactId>
    <version>1.0.4</version>
   </dependency>
   <dependency>
        <groupId>fr.opensagres.xdocreport</groupId>
        <artifactId>fr.opensagres.xdocreport.converter.odt.odfdom</artifactId>
        <version>1.0.4</version>
   </dependency>
<dependency>
  <groupId>xerces</groupId>
  <artifactId>xercesImpl</artifactId>
  <version>2.9.1</version>
  <optional>true</optional>
</dependency>

with code
InputStream in= new FileInputStream(new File("src/main/resources/demoOffice.odt"));
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(
    in, TemplateEngineKind.Freemarker);

// 2) Create Java model context 
IContext context = report.createContext();
context.put("name", "world");

// 3) Set PDF as format converter
Options options = Options.getTo(ConverterTypeTo.PDF);

// 4) Generate report by merging Java model with the ODT and convert it to PDF
OutputStream outputStream = new FileOutputStream(new File("src/main/resources/demoOffice_Out.odt"));
report.convert(context, options, outputStream);

in demoOffice.odt :    
hello ${name}!


I don't understand your problem. You can call repeatedly report.convert, no?

You say you try to convert a odt file, and first line of stacktrace says converter only support docx format. It may be the reason of the error (odt format is not docx format)

i was getting error because of this dependency :           
fr.opensagres.xdocreport fr.opensagres.xdocreport.document.odt
1.0.4
      now solved but now getting another exception:      fr.opensagres.xdocreport.core.XDocReportException: Null template engine. Set template engine IXDocReport#setTemplateEngine.  here --> IContext context = report.createContext();

as explained it misses 
fr.opensagres.xdocreport
fr.opensagres.xdocreport.template.freemarker
1.0.4


yes i added this and removed earlier exception now getting new exception edited above also::              fr.opensagres.xdocreport.core.XDocReportException: java.lang.NoSuchMethodError: freemarker.template.Configuration.setTagSyntax(I)V               java.io.FileNotFoundException: Template fr.opensagres.xdocreport.document.odt.ODTReport@fbe57c!content.xml not found.

I think you have not the well Freemarker version. I suggest you to see our odt+freemarker sample which is a maven project https://code.google.com/p/xdocreport/source/browse?repo=samples#git%2Fsamples%2Ffr.opensagres.xdocreport.samples.odtandfreemarker

XDocReport is modular, so you must choose :

your template engine implementation. In your case you wish to use Freemarker so you must declare in your pom : 


<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.template.freemarker</artifactId>
  <version>1.0.4</version>
</dependency>



the document kind (doc, odt, etc). In your case you wish to use odt so you must declare in your pom : 


<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.document.odt</artifactId>
  <version>1.0.4</version>
</dependency>



the converter if you wish to convert report to other format than original. In your case you wish to convert ODT to PDF, so you must declare in your pom : 


<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.xdocreport.converter.odt.odfdom</artifactId>
  <version>1.0.4</version>
</dependency>


Those dependencies are explained here

thx for reply ...i already added this and removed earlier exception but now i m getting this error ...edited above
