I have a document that I add an image to via an application using java. The image displays fine. However I am running into a really strange problem. It seems Word (2003) is modifying the document causing the image to be lost. Here is what I mean.
In my document I have 2 images
rId4 was inserted using Word.
rId8 was inserted via the program. I open the doc in word and both images are displayed just fine. However after I close the document without modifying it at all,
rId8 is changed to an external reference and lost.
rId4 is OK.
So prior to opening the document the word/_rels/document.xml.rels contains the following :
<?xml
version="1.0" encoding="UTF-8" ?>
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Target="webSettings.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" />
<Relationship Id="rId2" Target="settings.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" />
<Relationship Id="rId1" Target="styles.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" />
<Relationship Id="rId6" Target="theme/theme1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" />
<Relationship Id="rId5" Target="fontTable.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" />
<Relationship Id="rId4" Target="media/image1.jpeg" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" />
<Relationship Id="rId7" Target="vbaProject.bin" Type="http://schemas.microsoft.com/office/2006/relationships/vbaProject" />
<Relationship Id="rId8" Target="media/sig.jpeg" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" />
</Relationships>
After closing the document. word/_rels/document.xml.rels contains the following :
<?xml
version="1.0" encoding="UTF-8" standalone="yes" ?>
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"
/>
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"
/>
<Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"
/>
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"
/>
<Relationship Id="rId1" Type="http://schemas.microsoft.com/office/2006/relationships/vbaProject" Target="vbaProject.bin"
/>
<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="ooxWord://word/media/sig.jpeg" TargetMode="External" />
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.jpeg"
/>
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml"
/>
</Relationships>
Notice that the relationships have now been reordered and
rId6 (the image in question) is now marked as External. I don't care if that Word reorders the relationships, but why is it marking the image as external? I am probably missing something when I add the image to the package but what?? I have tried to set the TargetMode to internal before opening the document which seems to have no effect. Also the jpeg is also removed from the package. Has anyone run into this problem before?