Problem copying headers with images

Nov 3, 2009 at 8:48 PM

I'm running into a problem using DocumentBuilder to append documents.  The created document won't open in Word.  It seems to be missing _rels files for headers that contain images that are detected as duplicate images.  For example, the word folder contains a header6.xml file that contains a reference to an image  (<v:imagedata r:id="R4d08269be99f432b" o:title="" />).  In the words/_rels folder, there is a header6.xml.rels file that references an image in the media folder.  There is also a header8.xml file that contains a reference to the same image.  But there is no corresponding header8.xml.rels file in the word/_rels folder.  I'm not sure if that's a problem in the DocumentBuilder class (I'm using the one in PowerTools for Open XML 1.1.1), or a problem with annotations and FlushParts, or a problem with the SDK (I'm using 2.0).  I haven't been able to find a workaround yet.  By the way, the OpenXMLValidator class doesn't detect this problem.

I ran into a couple of other issues where I have found a workaround.

  • In DocumentBuilder.FixRanges, line 440, I hit an exception.  Should the call to First() be changed to FirstOrDefault()?  It's worked for me so far.
  • Bookmarks don't get new id's, so if the documents you are appending each have a bookmark with id = 1, the final document has duplicate bookmark id's.  I don't need bookmarks, so I'm deleting them before I append documents as my workaround.

I also hit a problem that is probably an issue with ofc.exe.  It generated styles with the sz and szCs elements, and set the val attribute on these elements to 0.  The OpenXMLValidator complains that the minimum for val should be 2.  It's easily fixed - I'm only mentioning it here since I suspect you have a hand in maintaining that program.


May 11, 2010 at 2:13 PM

Hi rknorp,

Did you ever find a solution for this? Iv tried to change the Fixranges Method as you stated but this hasn't helped. No-one else has been any help anywhere so im hoping you can help me out.