This project has moved. For the latest updates, please go here.

Image not inserted in resulted docx document.

Apr 15, 2014 at 3:52 PM
Edited Apr 15, 2014 at 4:06 PM
Hi all,
I have a problem regarding images in resulted docx by converting from html.

As i saw, when converting " var paragraphs = converter.Parse(htmlText); ", paragraphs.count = 0.
So, that converter does not even see my paragraphs with image/images.. It sees my html empty.
MemoryStream generatedDocument = new MemoryStream();

            using (WordprocessingDocument package = WordprocessingDocument.Create(generatedDocument, WordprocessingDocumentType.Document))
            {
                MainDocumentPart mainPart = package.MainDocumentPart;
                if (mainPart == null)
                {
                    mainPart = package.AddMainDocumentPart();
                    new DocumentFormat.OpenXml.Wordprocessing.Document(new Body()).Save(mainPart);
                }

                HtmlConverter converter = new HtmlConverter(mainPart);
                Body body = mainPart.Document.Body;

                var paragraphs = converter.Parse(htmlText);
                for (int i = 0; i < paragraphs.Count; i++)
                {
                    body.Append(paragraphs[i]);
                }

                mainPart.Document.Save();

                return generatedDocument;
            }
I notice that i use version 1.5 HtmlToOpenXml.
How can i show you my htmlText because i cannot paste it here, characters limited.

Obs1: it really doesn't matter what image extension i use (png,jpeg.. etc)
Obs2: checked that htmlBody in IE/Chrome and it works great.
Coordinator
Apr 15, 2014 at 11:23 PM
Hi Erik,


This is a recurring error that occurs with image.
Do you check the documentation? You are probably behind a proxy and thus you need to provide your credentials.

Do not hesitate to come back if the documentation doesn't help you.


Olivier
Apr 16, 2014 at 8:05 AM
Hi Oliver,
Yes i do read the documentation and also i do read the others's image problem. I downloaded yesterday the latest dll and still does not work. However, i found only one image that is rendering ok, but the rest don't. This makes me think is not a problem with a proxy or smthing else. In my html i have the bytes (inline base 64) of the image/images , so there is nothing to do with uploading from computer.
In order to prove this give me an email or smthing else to send you the html....

Erik
Coordinator
Apr 18, 2014 at 12:44 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.