Hi.
I did the following groovysript for create a document:
import fr.opensagres.xdocreport.core.XDocReportException;
import fr.opensagres.xdocreport.document.IXDocReport;
import fr.opensagres.xdocreport.document.registry.XDocReportRegistry;
import fr.opensagres.xdocreport.template.IContext;
import fr.opensagres.xdocreport.template.TemplateEngineKind;
import java.io.*;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeManager;
OfficeManager officeManager = null;
try{
// 1) Load ODT file and set Velocity template engine and cache it to the registry
InputStream inp= new FileInputStream(new File(“D:/document.odt”));
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(inp,TemplateEngineKind.Velocity);
// 2) Create Java model context
IContext context = report.createContext();
context.put(“namePerson”, “${namePerson}”);
context.put(“lastnamePerson”, “${lastnamePerson}”);
// 3) Generate report by merging Java model with the ODT
OutputStream out = new FileOutputStream(new File(“D:/newDocument.odt”));
report.process(context, out);
officeManager = new DefaultOfficeManagerConfiguration().setOfficeHome(new File("C:/Program Files (x86)/OpenOffice 4")).buildOfficeManager();
officeManager.start();
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
createPDF(converter);
createPDF(converter);
}
finally
{
if(officeManager != null){
officeManager.stop();
}
}
public static void createPDF(OfficeDocumentConverter converter){
try{
converter.convert(new File(“D:/newDocument.odt”), new File(“D:/newDocument_Pdf.pdf”));
}catch(Throwable e){
e.printStackTrace();
}
}
I added the jars in “Manage jars”
I don’t know what is the problem, I test this in other IDE, the script works.