Free Support Forum - aspose.com

Converting HTML to Word and inserting it into a docx document

Received : 2007/10/17 10:21:41
Message : I would like to know what calls are associated with convertng HTML to a word format and inserting it into a docx document.


This message was posted using Aspose.Live 2 Forum

Hi

Thanks for your request. See the following code.

//open html file

Document doc = new Document(@"274_98983_bryangrossman\in.html");

//save html file as Doc file

doc.Save(@"274_98983_bryangrossman\out.doc", SaveFormat.Doc);

//open docx file

Document doc1 = new Document(@"274_98983_bryangrossman\in.docx");

//inser the first document into the docx document

InsertDocument(doc1.LastSection.Body.LastParagraph, doc);

//save file as DOCX

doc.Save(@"274_98983_bryangrossman\out.docx", SaveFormat.Docx);

The InsertDocument Method you can find here.
http://www.aspose.com/Products/Aspose.Words/Api/InsertOneDocumentintoAnotheratAnyLocation.html

Also you can use DocumentBuilder.InsertHtml method to insert html into the document see the following link.
http://www.aspose.com/Products/Aspose.Words/Api/InsertingHTML.html

Best regards.

That is great… BUT is the html converted? or is it just HTML in a word document? If it is is there a way to actually convert it. Not just save it as a doc with embedded HTML?

Yes, HTML is converted.

Best regards.