I have code that creates a Word document using the OpenXml SDK. Part of the code adds an image to the front page of the document, and everything works perfectly. When I add code to include an image in the header as well, the front page image no longer displays--it doesn't even show a placeholder or a red x indicating the image is not found. The header image does display as expected.
I use the same function (BuildImage) to create the Drawing object in both cases. When building the header, if I comment out the line that appends that drawing, then the front page image remains. If I leave it in, then the front page image disappears.
Header h = new Header();
Paragraph p = new Paragraph();
Run r = new Run();
Drawing drawing = BuildImage(imageRelId, "logo_small.jpg", 150, 47);
r.Append(drawing); <-- This line causes the issue. If skipped, the image appears on front page
p.Append(r);
h.Append(p);
I have verified the document.xml, header.xml, all _rels files, etc after unzipping and everything looks fine to me. The image paths and media folder look good as well. If I do a comparison of the document.xml with and without the header image in the Word file, they are identical. I have no idea why the front page image will not show up.
I'm not sure if something changed in Word recently because everything did use to work using this code that has been untouched for over a year. This just started happening about a week ago.