I am attempting to iterate through the images in a PowerPoint presentation using OpenXML.
I have worked out how to do that.
I am now attempting to get the Images Alt-Text Title....
Here is my code:
List<ImagePart> imageParts = new List<ImagePart>();
part.GetPartsOfType<ImagePart>(imageParts);
foreach (ImagePart imagePart in imageParts)
{
if (imagePart != null)
{
// Get the Relationship Id
string oldRelID = part.GetIdOfPart(imagePart);
// Get the Alt-Text Tile relating to this image
}
}
Any OpenXML experts out there that could give me some pointers?
Thanks
UPDATE:
I have tried iterating through the XML but when there are multiple images on the slide I am getting the incorrect value for title for the relating image.
I think I need to be able to use the ImagePart Id to then find the corresponding title
The code below gets the titles out of order...
foreach (ImagePart imagePart in imageParts)
{
string mapReference = "";
XmlNode thisNode = pictureNodeList[imageCounter];
foreach (XmlNode xmlnode in thisNode)
{
foreach (XmlNode xmlchildnode in xmlnode)
{
foreach (XmlAttribute att in xmlchildnode.Attributes)
{
if (att.Name == "title")
{
mapReference = att.Value;
imageCounter += 1;
}
}
}
}
}