0
votes

We have recently been using docx4j for a project that requires generating docx from templates with variable injection. To do this, we had purchased the plutext-enterprise libs to be able to merge of multiple documents coupled with variable injection:

 <dependency>
            <groupId>com.plutext</groupId>
            <artifactId>Plutext-Enterprise</artifactId>
            <version>6.1.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.docx4j</groupId>
            <artifactId>docx4j</artifactId>
            <version>6.0.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-compress</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

The issue is that when the generated document is opened, an error showing "unreadable content" is displayed and asks if we would like to repair the document. Ultimately, I would like to remove this. I've tried a number of things such as upgrading the version of docx4j, but I've kept within the compatibility matrix outlined when using the enterprise libraries.

In addition, I've tried running a test with a completely blank template document to eliminate anything wrong with the content in the doc and the generated document still shows this error. This leads me to believe this is an issue with the library itself. Can anyone advise further on this?

1

1 Answers

1
votes

The issue will be that Microsoft has introduced new namespaces prefixes which need to be declared. The solution is to upgrade docx4j to v8.2.9: https://www.docx4java.org/forums/announces/docx4j-8-2-9-released-following-word-updates-t2979.html

Your existing Enterprise jar should be ok with that, but more recent versions are available so upgrading is an option.