[英]How get images from .docx to stream with Aspose.Words
Task is to replace disk operations with streams. 任务是用流替换磁盘操作。 When .docx saved to disk - works perfectly.
将.docx保存到磁盘时-可以正常工作。 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. 在doc.Save()上,它将进行回调,其中图像的图像流为空-但是图像存在于Word文档中。
Are there any ideas ? 有什么想法吗?
e.ImageStream allows you to specify the stream where image will be saved. e.ImageStream允许您指定要保存图像的流。 If this property is null, it means image will be saved to disk and not to a stream.
如果此属性为null,则表示图像将保存到磁盘而不是流中。 You can pass a stream object to this property and image will be saved to that stream object eg
您可以将流对象传递给该属性,图像将保存到该流对象,例如
Stream imageStream = new MemoryStream();
e.ImageStream = imageStream;
This will save the image to imageStream object after the ImageSaving is called. 这将图像保存到的ImageStream对象ImageSaving被调用后。
I work as developer evangelist at Aspose. 我在Aspose担任开发人员推广员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.