Dear experts,
now i have a requirement to develop a translate powerpoint content.
I use OpenXML to extract the data from slide. But the result is all text in the slide.
is there any Class/API to get these text by its container which is in the powerpoint selection pane?
because i will write back the translated text to the same container.
Attach my current code, FYI:
public Dictionary<int,string> GetSlideIdAndText(string filePath, int index){
Dictionary<int, string> slideTexts = new Dictionary<int, string>();
using (PresentationDocument ppt = PresentationDocument.Open(filePath, false))
{
// Get the relationship ID of the first slide.
PresentationPart part = ppt.PresentationPart;
OpenXmlElementList slideIds = part.Presentation.SlideIdList.ChildElements;
string relId = (slideIds[index] as SlideId).RelationshipId;
// Get the slide part from the relationship ID.
SlidePart slide = (SlidePart)part.GetPartById(relId);
// Get the inner text of the slide:
IEnumerable<A.Text> texts = slide.Slide.Descendants<A.Text>();
int i = 1;
foreach (A.Text text in texts)
{
slideTexts.Add(i,text.Text);
i++;
}
}
return slideTexts;
}
}