We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Picture is not replaced properly


We are using ASPOSE Words version to replace smart tags with images. If the smart tag is in a table then the image is not properly displaying in the replaced document.

Here is the code snippet which we are using.

Dictionary smartTagDictionary = new Dictionary();
smartTagDictionary.Add("PropertyPhoto.FullSize1", @"c:\P1.JPG");

Aspose.Words.Document doc = new Aspose.Words.Document(@"c:\testtemplate.doc");
doc.Range.Replace(new Regex("<>"), new SmartTagReplaceEvaluator(smartTagDictionary), true);

public class SmartTagReplaceEvaluator : IReplacingCallback

private Dictionary _smartTagDictionary;
public SmartTagReplaceEvaluator(Dictionary SmartTagDictionary)
_smartTagDictionary = SmartTagDictionary;
ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
string tag = e.Match.Value;
string smartTagValue = _smartTagDictionary[tag.Replace("<>", string.Empty).Trim()];

if (!string.IsNullOrEmpty(smartTagValue) && (tag.Contains("Photo"))
DocumentBuilder builder = new DocumentBuilder(e.MatchNode.Document as Aspose.Words.Document);
e.Replacement = smartTagValue;

// Signal to the replace engine to do nothing because we have already done all what we wanted.
return ReplaceAction.Replace;

Please find the attached zip file containing source document, sample images and replaced document. Please look in to this issue.




Thank you for your inquiry.
Your images that you insert into table cells is much more than can display the page layout. I tried to do the same thing in MS Word and I see exactly the same result. I've attached a file created in MS Word with manually inserting images. Aspose.Words is doing everything exactly the same as MS Word.

Please describe exactly what you want to see in the output document.

Thanks for the information.

We are expecting to see the full picture in the table cell. Currently part of the picture is displaying in the cell.


Hello Balaji.
Thank you for additional information.
As I mentioned earlier, a document created in MS Word looks exactly the same as the document was created using Aspose.Words. Rather one can say exactly on turnover - Aspose.Words does everything as well as MS Word. You can reduce the images themselves, which you put in a table cell. Try using the following code:

// Get all shapes in the document.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);

// Loop through all shapes.

foreach (Shape shape in shapes)


if (shape.HasImage)


// Working with shape

// Reducing image size to 50%

shape.Height = shape.Height * 0.50;

shape.Width = shape.Width * 0.50;



Thanks for the information.We checked and found that Aspose is converting same as the document created through MS Word.

When we convert same document to PDF the images are not showing properly. We are using Aspose.Words.Document.Save function to do this. Please find the attached source and PDF files.


Hi Balaji,

Thank you for reporting this problem to us. I managed to reproduce it on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.

Best regards,

The issues you have found earlier (filed as WORDSNET-4464) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.