Free Support Forum -

HtmlSaveOptions always renders the same image with different value

I have these lines of code:

Aspose.Words.Saving.HtmlSaveOptions options = new Aspose.Words.Saving.HtmlSaveOptions(Aspose.Words.SaveFormat.Html);
string strRootFolder = HttpContext.Current.Server.MapPath("/");
string strPoliciesImagesFolder = “/Uploads/PoliciesAndProcedures/WordImages”;
string strFullPathImagesFolder = strRootFolder += strPoliciesImagesFolder.Replace("/", “\”);
if (!Directory.Exists(strFullPathImagesFolder))
options.ImagesFolder = strFullPathImagesFolder;
options.ImagesFolderAlias = strPoliciesImagesFolder;
doc.Save(stream, options);

But I need to be able to have same image to have the same ID each time instead of creating a new one. Is this possible? Thank you in advanced.

Hi Vlad,

Thanks for your inquiry. Could you please attach your input Word document and expected output Html here for our reference? We will then provide you more information on this along with code.

I don’t really have an expected HTML output here, but I would like to be able to handle the name of each of the images in order to not have them saved as different images everytime the word document gets read with the same image. Thank you.

Hi Vlad,

Thanks for your inquiry. Please implement IImageSavingCallback interface if you want to control how Aspose.Words saves images when saving a document to HTML. Please check the following code example.

Unfortunately, your question isn't clear enough therefore we request you to please elaborate your inquiry further by providing complete details of your use case. This will help us to understand your scenario, and we will be in a better position to address your concerns accordingly.

Document doc = new Document(MyDir + "in.docx");

// Create and pass the object which implements the handler methods.

HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);

options.ImageSavingCallback = new HandleImageSaving();

doc.Save(MyDir + "Out.html", options);

public class HandleImageSaving : IImageSavingCallback


void IImageSavingCallback.ImageSaving(ImageSavingArgs e)


e.ImageFileName = "new image name";