Skip to content

Frequently Asked Questions

Tom Hombergs edited this page Jan 1, 2016 · 5 revisions

Why doesn't the .docx document show special characters in expression replacements?

Probably because you're providing replacement strings that are not UTF8 encoded, for example if the replacement string in your context object is defined as String variable in a ISO-8859-1 encoded java source file. The solution to this problem is to make sure that all your replacement strings come from an UTF8 encoded source. Other encodings are not supported by the Office Open XML standard.

Why are dates not formatted correctly?

By default, Date objects are formatted "dd.MM.yyyy" when an expression in the template is replaced by a Date. You can change this behavior by simply registering a new DateResolver with your own formatting String, for examle "yyyy-MM-dd HH:mm":

DocxStamper stamper = new DocxStamper();
stamper.getTypeResolverRegistry()
  .registerTypeResolver(new DateResolver("yyyy-MM-dd HH:mm"));