Currently , I'm working on a project that use this awesome library. I'm facing a problem that I can't deal with.
I would like to add an image in a DocX using code ( as BitmapSource)
I made this exemple :
using (DocX doc = DocX.Load(@"input.docx")) // input.docx is an empty docx created with Word 2010
Novacode.Paragraph paragraphFirst = doc.Paragraphs.First();
BitmapSource bitmapSource = new BitmapImage(new Uri(@"image.bmp"));
MemoryStream memoryStream = GetStreamFromBitmapSource(bitmapSource);
image = doc.AddImage(memoryStream);
Picture picture = image.CreatePicture();
public static MemoryStream GetStreamFromBitmapSource(BitmapSource bitmapSource)
BitmapEncoder encoder = new PngBitmapEncoder();
MemoryStream ms = new MemoryStream();
The error is located in the method : CreatePicture()
What is wrong in this code ?
Thanks for any help that you can provide.