Image problem in converting HTML to MS Word doc

S

s.danyal.k

Hi All,
I have created an application in C# that converts HTML file to MS word
documents. The HTML file may also have images , for e.g "<img
src='http://www.google.com.pk/images/hp0.gif'></img>".
The HTML file saved into .doc file. Now the problem is
that whenever the .doc file is opened it goes to the link mentioned in
the <img> tag. This means that only the link is saved in the .doc file
and not the ACTUAL image. Now I want the actual image to be saved in
the .doc file and not the link to that image. Any idea on this problem
will be appreciated.

Danyal
 
G

Guest

I don't know what you are doing to "convert" your HTML into a word document
file, but in this case your code would need to :

1) Download each image from its url in the HTML document.
2) Convert the image to its Word Doc counterpart using the Word object
model, or
3) Convert the image to its proper MIME -encoding (normally Base64) and
insert the proper MIME boundary headers.

Hope that helps.
Peter
 
P

Peter Jamieson

Something along the following lines may be enough - there are other ways to
insert images that are not inline.

Dim strImagePath as String
strImagePath = "http://www.google.com.pk/images/hp0.gif"
rngSomeRange.InlineShapes.AddPicture _
FileName:=strImagePath, _
LinkToFile:=False, _
SaveWithDocument:=True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top