Convert doc/docx to semantic HTML

2019-02-15 20:37发布

问题:

I would like to convert doc/docx documents to semantic HTML.

Some wishes/requirements:

  1. Semantic HTML such that headers in the document are <h1>, <h2> etc., tables are <table> and so forth.

  2. Should preferably be possible to handle headings, lists, tables and images. Graphs and math formulas is a nice extra.

• Doesn't have to be converted straight from doc/docx to html, could use an intermediary format, such as xml or docbook.

• Should work programatically, and with large number of documents.

The closest thing to a solution I've found so far is http://holloway.co.nz/docvert/index.html, but unfortunately there are many a few bugs, small user base and it can't handle a lot of documents. More of a proof of concept.

回答1:

There's a tool called upCast which is able to convert Word documents into XML.



回答2:

" headers in the document are " I think this is impossible. Because MS Word only write down the result, with different styles of <p> just like printed text on paper, the original info are not recorded.

Your other wishes could be approached. There're two commercial tools can do this (don't believe those free tools or online tools, they don't do the real work.)

1 Word Cleaner by Zapadoo www.zapadoo.com
2 HTML Cleaner for Word by wonder Studio www.htmlcleaner.com

I prefer the second one which released just last year. You can try them both.



回答3:

docx4j (for docx only, not doc) writes clean HTML output. You'd need to change things a bit if you wanted <h1> instead of <p class="h1">, but its open source so you can do that.



回答4:

I wrote a utility which implements the requirements you listed, excluding images, graphs and maths formulas. It's beta quality (i.e., it works on my machine). I published it at http://www.modeltext.com/word



回答5:

Just more ideas.

Use Gmail to convert word docs

http://www.oreillynet.com/mac/blog/2006/05/use_gmail_to_convert_word_docs.html