opensagres / xdocreport

XDocReport means XML Document reporting. It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).
https://github.com/opensagres/xdocreport
1.22k stars 372 forks source link

Unreadable content when opening generated file #553

Open Rizen59 opened 2 years ago

Rizen59 commented 2 years ago

Context:

Using the following simple trame : report.docx Generate the report:

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

    IContext context = report.createContext();

    OutputStream out = new FileOutputStream(System.getProperty("java.io.tmpdir") + "trame-" + System.currentTimeMillis() + ".docx");
    report.process(context, out);
} catch (Exception e) {
    e.printStackTrace();
}

Problem:

When opening the generated docx file Word display a Warning message : image Translation: The file cannot be opened because there are problems with the contents Reproduced with xdocreport 2.0.2 and 2.0.3

First observations:

For now I can't find what is exactly the cause of the problem. But it works well when we apply one of these changes :