HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sURI);(sURI is like http://localhost/test/test.dll/........")
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string strHTML = reader.ReadToEnd();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(strHTML);
doc.Save(@"c:\Test.doc");
strHTML is a string with similar HTML below..
Can you please tell me what’s wrong? Why it’s not displaying 1st image in word ? When I call InsertHTML should it download chart image on PC? Because it’s not downloading it here.
To download images when importing HTML we use the same classic approach as you do to get your HTML. Here it is:
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
MemoryStream dstStream = new MemoryStream((int)response.ContentLength);
using (Stream responseStream = response.GetResponseStream())
CopyStream(responseStream, dstStream);
In your code sample try to specify the URL of the image to obtain image data, not HTML document (i.e. http://localhost/test/test.dll/Chart.jpg?param1=1000&userid=test@test.com&password=2006) and see if the data is actually produced by your dll and loaded into response stream.
Fixed this in the attached Aspose.Words 4.0.3.3 build.
The problem was that your webserver did not return a valid response.ContentLength and Aspose.Words relied on it. Fixed so we do not require content length upfront.
I am sorry But that still didn’t fix the problem. I am still seeing red cross in place of images…and If I pass builder.Inserhtml(string ImageURL) then I am still seeing the url displayed in WORD.