Page 1 of 1

Issue loading Word 2013 docx

PostPosted: Fri Oct 24, 2014 5:43 am
by mistahmikey
A complete noob here. Tried to use the following code to load up a 2013 docx:

Code: Select all
package myartifact;

import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.apache.log4j.BasicConfigurator;

public class HelloMavenCentral {

   public static void main(String[] args) throws Exception {

      WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
      String filename = "C:\\Users\\Mike\\Desktop\\My.docx";

      wordMLPackage.load(new );


Bombs out trying to find the "officeDocument" relationship type. There is a hard coded check for: ... ceDocument

but what appears in the relationship specification for the actual document is: ... ceDocument

Here is the problematic code:

Code: Select all
package org.docx4j.openpackaging;

import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.relationships.Relationship;

public class PackageRelsUtil { 
   public static String getNameOfMainPart(RelationshipsPart packageRels) throws Docx4JException  {
      // find rel of type officeDocument
      for (Relationship rel : packageRels.getRelationships().getRelationship() ) {
         if (rel.getType().equals(
               "") ) {
            return rel.getTarget();
      throw new Docx4JException("No relationship of type officeDocument");

Let me know if there is anything I can do to avoid this.


Re: Issue loading Word 2013 docx

PostPosted: Fri Oct 24, 2014 6:19 am
by jason
Could you please attach your sample docx? Was it created in Word 2013, or some other way?