Just wanted to drop in an tell you to be weary of spaces in your hyperlinks. Especially in Word 2007.
I was getting the following message:
- Code: Select all
The file blah.docx cannot be opened because there are problems with the contents.
The file is corrupt and cannot be opened.
Word found unreadable content in blah.docx. Do you want to recover the contents of this document? If you trust the source of this document, click Yes.
Typically you specify hyperlink locations as a Relationship target like so:
- Code: Select all
Relationship relationship = factory.createRelationship();
relationship.setTarget(url);
Office 2007 will report a corrupt file (although it repairs successfully), if there are spaces in the URL. Simply delete the whitespace.
- Code: Select all
relationship.setTarget(StringUtils.deleteWhitespace(url));
Happy coding all!