This project has moved and is read-only. For the latest updates, please go here.

Adding an image into a docx

Jun 12, 2014 at 12:49 AM
Hi,

I cannot get an image to display in a document. It just says "this image cannot currently be displayed" using the code:
    Header headerDefault = document.Headers.odd;
     //image
    var img = document.AddImage(imageStream);//(@"../../Content/img/DMS-headerimage.jpg");
    Picture headerImage = img.CreatePicture(100, 100);
    Paragraph headerParagraph = headerDefault.InsertParagraph("", false);
    headerParagraph.InsertPicture(headerImage);
The code in your doc does not compile because of (no method takes 3 args):
    Picture pic1 = p.InsertPicture(img.Id, "Donkey", "Taken on Omey island");
Jun 12, 2014 at 9:56 AM
This might be the same issue that has been addressed here: http://docx.codeplex.com/discussions/352815
If that's true then it can either be solved by using AppendPicture in stead of InsertPicture, or by downloading the latest source code (if you are indeed using the dll and not the latest source code, that is).
Marked as answer by GarethReid on 6/12/2014 at 9:25 PM
Jun 13, 2014 at 5:25 AM
AppendPicture() works! Thanks heaps.