I am facing two issues with replacing image content control by its appropriate image.
Issue #1: How can we replace Text Content Control in the ms Word document with the Image Content Control dynamically and replace it with Image.
Issue #2: Also, I have tried replacing the image content control from a ms word document with an image using open XML. Its working when there is only one image content control.
If there are more than one content control it replaces all the images with the same image. Please suggest me how can we find out specific image content control from the document and replace it with image.
Below is the code I am using to replace the image content control with the image.
ImagePart image = (ImagePart)mainPart.GetPartsOfType<ImagePart>().First();
string signatureUrl = contactProfile[UserProfileProperties.SIGNATURE].Value.ToString();
System.IO.Stream data = Site.RootWeb.GetFile(signatureUrl).OpenBinaryStream();
image.FeedData(data);
I already have tried with below codes, in all the cases all the image content controls in the document are replaced by single image.
ImagePart image = (ImagePart)mainPart.GetPartsOfType<ImagePart>().Last();
ImagePart image = (ImagePart)mainPart.GetPartsOfType<ImagePart>().ElementsAt(0);
No comments:
Post a Comment