This project has moved and is read-only. For the latest updates, please go here.

HTML to Docx with styling

Feb 14, 2013 at 9:11 AM
Doesn't the styling work if I have the css file link along with the HTML? I am trying to convert HTML to docx using the below.
 const string filename = "C:\\Temp\\test.docx";

            if (File.Exists(filename)) File.Delete(filename);

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

                    HtmlConverter converter = new HtmlConverter(mainPart);                  

                    DocumentFormat.OpenXml.Wordprocessing.Body body = mainPart.Document.Body;

                    var paragraphs = converter.Parse(pageHtml);
                    for (int i = 0; i < paragraphs.Count; i++)

Is there any alternative to have styles functioning other than having them inline.

Please suggest.