Hello,
I need to export html pages to Doc. I’ve studying some libraries, how: Syncfusion, Microsoft.Office.Interop.Word, etc… After all tests, the Aspose library was where I got the most satisfactory result.
I do the insertion of html text directly using the method InsertHtml of the DocumentBuilder. But the images in the html document is not being sent to the document .doc created.
Sample code:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HttpContext.Current.Request.Url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
request.Method = “GET”;
request.ContentType = “application/msword”;
request.UserAgent = “Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0”;
BinaryReader resReader = new BinaryReader(resStream);
MemoryStream imgStream = new MemoryStream(resReader.ReadBytes((int)response.ContentLength));
StreamReader reader = new StreamReader(imgStream);
string text = reader.ReadToEnd();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(text);
doc.Save(“example.doc”, SaveFormat.Doc, SaveType.OpenInApplication, Response);
The images aren’t retrieved and sent to the created document.
Below is an example of the use of images:
I count on the assistance of everyone to continue using the library.
Thanks.