public string CreateImageUri(string rootUri, OfficeImage image, string relativeUri) { string imageName = String.Format("image{0}", imageId); imageId++; //RichEditImage richEditImage = RichEditImage.CreateImage(image); OfficeImageFormat imageFormat = GetActualImageFormat(image.RawFormat); Stream stream = new MemoryStream(image.GetImageBytes(imageFormat)); string mediaContentType = OfficeImage.GetContentType(imageFormat); AttachementInfo info = new AttachementInfo(stream, mediaContentType, imageName); attachments.Add(info); return("cid:" + imageName); }
protected internal virtual AlternateView CreateHtmlView() { control.BeforeExport += OnBeforeExport; string htmlBody = control.Document.GetHtmlText(control.Document.Range, this); AlternateView view = AlternateView.CreateAlternateViewFromString(htmlBody, Encoding.UTF8, MediaTypeNames.Text.Html); control.BeforeExport -= OnBeforeExport; int count = attachments.Count; for (int i = 0; i < count; i++) { AttachementInfo info = attachments[i]; LinkedResource resource = new LinkedResource(info.Stream, info.MimeType); resource.ContentId = info.ContentId; view.LinkedResources.Add(resource); } return(view); }