template/xdocreport/src/main/java/de/taimos/dvalin/template/xdocreport/ReportService.java
/**
     * @param template   the name of the template file relative to /xdocreport/
     * @param contextMap the KV map containing the context to replace
     * @param out        the stream to write the created PDF to
     */
@param template   the name of the template file relative to /xdocreport
@param contextMap the KV map containing the context to replace
@param out        the stream to write the created PDF to
@param template the name of the template file relative to / xdocreport @param contextMap the KV map containing the context to replace @param out the stream to write the created PDF to
public void generatePDF(String template, Map<String, Object> contextMap, OutputStream out) {
        try {
            InputStream in = ReportService.class.getResourceAsStream("/xdocreport/" + template);
            IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in, TemplateEngineKind.Velocity);
            IContext context = report.createContext();
            context.putMap(contextMap);
            context.put("dateTool", new DateTool());
            report.convert(context, Options.getTo(ConverterTypeTo.PDF), out);
        } catch (IOException | XDocReportException e) {
            throw new RuntimeException("Error creating PDF", e);
        }
    }
public void generatePDF ( String template , Map < String , Object > contextMap , OutputStream out ) { try { InputStream in = ReportService . class . getResourceAsStream ( "/xdocreport/" + template ) ; IXDocReport report = XDocReportRegistry . getRegistry ( ) . loadReport ( in , TemplateEngineKind . Velocity ) ; IContext context = report . createContext ( ) ; context . putMap ( contextMap ) ; context . put ( "dateTool" , new DateTool ( ) ) ; report . convert ( context , Options . getTo ( ConverterTypeTo . PDF ) , out ) ; } catch ( IOException | XDocReportException e ) { throw new RuntimeException ( "Error creating PDF" , e ) ; } }
@param template   the name of the template file relative to /xdocreport
 @param contextMap the KV map containing the context to replace
 @param out        the stream to write the created PDF to
@param template the name of the template file relative to / xdocreport @param contextMap the KV map containing the context to replace @param out the stream to write the created PDF to
// Load .docx file by filling Velocity template engine and cache it to the registry // Create context Java model // Generate report by merging Java model with the docx file