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.23k stars 374 forks source link

Create PDF from Word with { DATE } field supported? #175

Open twiedow opened 7 years ago

twiedow commented 7 years ago

I have a word docx file which contains a field with value { DATE \@ "dd.MM.yyyy" * MERGEFORMAT }. When I export this from Word as PDF the field is replaced as expected with the current date.

Is this also supported by XDocReport?

At the moment I just see that the date is not set correctly when exported via XDocReport (using Velocity, XWPF and PDF).

IXDocReport report = XDocReportRegistry.getRegistry().loadReport(new ByteArrayInputStream(docxData), TemplateEngineKind.Velocity);

Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.XWPF);

IContext context = report.createContext();

if (fieldValues != null && fieldValues.size() > 0) {
  context.putMap(fieldValues);
}

ByteArrayOutputStream out = new ByteArrayOutputStream();
report.convert(context, options, out);
angelozerr commented 7 years ago

No XDocReport doesn't support that.