Picture not displayed when replacing text with image:
Code:
TextSelection selPics = p.Find(new Regex(@"(<@Picture//PictureSize)[^<]*@>"));
string reportPDFImageFormat = ConfigurationManager.AppSettings["reportPDFImageFormat"]; // medium
if (selPics != null)
{
string imgUrl =get image url();
if (!string.IsNullOrEmpty(imgUrl))
{
using (var image =getImagefromUrl)
{
//Load picture in function of tag (checks for custom size)
DocPicture pic = new DocPicture(document);
pic.LoadImage(image);
pic = GetDocPictureFromImage(ref pic, selectionPictures.SelectedText, 200);
//replace template with picture
TextRange range = selPics.GetAsOneRange();
int index = range.OwnerParagraph.ChildObjects.IndexOf(range);
range.OwnerParagraph.ChildObjects.Insert(index, pic);
range.OwnerParagraph.ChildObjects.Remove(range);
}
}
The same code works for other picture placements.