0

I am trying to convert HTM to docx without using interop dll. I have tried with Dynamically generate a MS Word document using HTML & CSS and also with Html to OpenXml.

I don't find a way to convert with HTML to Docx with all the styles and images intact. Openxml does support styles but only when styles are inline. If I have the styles defined in CSS file then the styles does not get reflected.

What alternative can I go for to achieve this?

Akram Shahda
  • 14,655
  • 4
  • 45
  • 65
San
  • 1,797
  • 7
  • 32
  • 56

1 Answers1

0

Queston 1 - Preserve Styling

Pre-process the HTML to inline the styles from the css file before using html2openxml to convert the document.

Question 2 - Preserve Images

Images are supposed to work in that converter according to here http://html2openxml.codeplex.com/wikipage?title=ImageProcessing&referringTitle=Documentation

maybe you need to debug this a bit / post more info

Edit Maybe you forgot to set the base path

converter.BaseImageUrl = new Uri("http://myserver:8080/");
DaveDev
  • 41,155
  • 72
  • 223
  • 385
Dreamwalker
  • 3,032
  • 4
  • 30
  • 60
  • I will try out to Pre-process the HTML to inline the styles from the css and see if it work. – San Feb 14 '13 at 11:55
  • I have had a look to see if something already exists but having no look. If you keep your css simple so the full styling is on one css class will make this easy otherwise you will need to trace the needed styles in the document which will make this harder to code. – Dreamwalker Feb 14 '13 at 12:00
  • Someone has posted a css inline on here http://stackoverflow.com/questions/3679213/inlining-css-in-c-sharp – Dreamwalker Feb 14 '13 at 13:35
  • 1
    That doesn't look like will work for css styles. But is meant for styles defined on the page in head section. ia m trying with http://stackoverflow.com/questions/5066667/net-convert-external-css-to-inline-css – San Feb 15 '13 at 06:36