When testing docx4j using the blog sample project provided under
http://muammeryucel.blogspot.com/2011/01/manipulating-microsoft-docx-files-with.html, I recognized that the sample code works only if the document path to the template does not contain spaces.
The sample code has,
- Code: Select all
invitation = new Invitation(templateProperties, InvitationTest.class
.getResource("/template.docx").getPath(), InvitationTest.class
.getResource("/").getPath());
with Invitation having
- Code: Select all
WordprocessingMLPackage template = WordprocessingMLPackage
.load(new File(templateFilePath));
resulting in the following docx4j stack trace
org.docx4j.openpackaging.exceptions.Docx4JException: Couldn't load file from C:\Users\Karsten%20Tinnefeld\Desktop\hello.world.docx4j\target\test-classes\template.docx
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:186)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:169)
at com.myucel.docx4j.Invitation.invite(Invitation.java:44) ...