class XDocReportService {

    @Programmatic
    public byte[] render(
            final byte[] templateBytes,
            final XDocReportModel dataModel,
            final OutputType outputType) throws IOException {
        try {
            final byte[] docxBytes = toDocx(templateBytes, dataModel);

            switch (outputType) {
            case PDF:
                return toPdf(docxBytes);
            default: // ie DOCX
                return docxBytes;
            }

        } catch (XDocReportException e) {
            throw new IOException(e);
        }
    }

}