using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
...
WordDocument documento = new WordDocument(ruta);
...
documento.MailMerge.MergeImageField += new MergeImageFieldEventHandler(Catalogo);
documento.MailMerge.ExecuteGroup(ds.Tables["Datos"]);
MemoryStream mStream = new MemoryStream();
mStream.Position = 0;
documento.Save("Documento.docx", FormatType.Docx, HttpContext.Current.Response, HttpContentDisposition.Attachment);
...
private void Catalogo(object sender, MergeImageFieldEventArgs args)
{
if (args.FieldName == "Foto")
{
Uri url = new Uri(args.FieldValue.ToString());
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream stream = httpWebReponse.GetResponseStream();
args.Image = System.Drawing.Image.FromStream(stream);
}
}
Añadir una imagen usando MailMerge y DocIO de Syncfusion
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.