I need to get relationship id
of a Drawing object to extract images from Word using OpenXml
. I saw Replace image in word doc using OpenXML and I'm using this code now:
string imageId = "default value";
Blip blipElement = selectedImage.Descendants<Blip>().First();
if (blipElement != null) {
imageId = blipElement.Embed.Value;
}
document.MainDocumentPart.GetPartById(imageId);
Works perfectly for usual images, but doesn't work for powerpoint slides which are stored as EMF images inside docx, because EMF Drawing's don't have Blip. But they have ImageParts
just like the usual images and I can see them. So, the question is, how do I find an imageId from a Drawing to get those EMF ImageParts? Unfortunately, I can't extract images the other way, because I'm trying to inject my code into a huge existing codebase, so I need to get it from a Drawing object.