Reputation: 480
Task is to replace disk operations with streams. When .docx saved to disk - works perfectly. Tried to change using streams.
Have following code:
var options = new HtmlSaveOptions(SaveFormat.Html)
{
ImageSavingCallback = new HandleImageSaving()
};
Stream stream = new MemoryStream();
doc.Save(stream, options);
stream.Position = 0;
public class HandleImageSaving : IImageSavingCallback
{
void IImageSavingCallback.ImageSaving(ImageSavingArgs e)
{
// here e.IsImageAvailable == true
// but e.ImageStream == null
}
}
On doc.Save() it goes callback where imagestream for image is empty - but images exist in word document.
Are there any ideas ?
Upvotes: 0
Views: 1129
Reputation: 141
e.ImageStream allows you to specify the stream where image will be saved. If this property is null, it means image will be saved to disk and not to a stream. You can pass a stream object to this property and image will be saved to that stream object e.g.
Stream imageStream = new MemoryStream();
e.ImageStream = imageStream;
This will save the image to imageStream object after the ImageSaving is called.
I work as developer evangelist at Aspose.
Upvotes: 1