Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have files that I want to make available in an variety of formats:

  • HTML
  • PDF
  • EPUB
  • Plain Text (maybe)

Most of the files will be sourced in doc, docx, or rtf format, so that needs to be considered.

So I need some kind of format that converts well from docx, doc, and rtf and has plenty of libraries for converting into PDF, EPUB, HTML etc. Ideally libraries in Python, but Java is also okay.

share|improve this question

closed as too broad by gnat, GlenH7, MichaelT, Kilian Foth, Bart van Ingen Schenau Sep 5 '14 at 7:47

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

This sounds like a job for.... XML!!! ...You can use XSL transformations to convert your intermediate XML format into some alternate format (which does not need to be XML). – FrustratedWithFormsDesigner Nov 2 '12 at 21:04
flagged as "not constructive" this is essentially a request for the "best" tool for a task, which is subjective and has no definitive answer (for the record, I like the question and I think it could be rewritten to fit the site format). PS my preference is org mode – Abe Nov 3 '12 at 6:35
Jordan, what is the purpose? Is that intermediatd file format will ever be edited manually (possibly using some special editor)? @Abe: This is a constructive question, in my opinion. You only need to want to understand what Jordan asks. – pepr Nov 5 '12 at 8:15
up vote 3 down vote accepted

"doc" and "rtf" can be easily converted to "docx" using MS Word. "docx" can be can be converted to PDF, EPUB, HTML or plain text either by Word's buildin converters, or by third party tools.

Here is a link telling you more about a clean Word->HTML conversion:

For Word->EPUB a simple google search will reveal you some free online converters and some commercial tools.

If, for what reasons ever, you don't like that solution and want a more "vendor neutral" intermediate format, then use docbook. But don't expect that this will increase the overall quality of the results, since every additional step in the conversion chain will most probably add some additional data loss.

share|improve this answer

When searching for the intermediate format, there is always a problem with presentational vs. structural markup problem.

Typically, DocBook or LaTeX sources use the clear structural markup with usually few exceptions (misuses) caused by the author.

On the other hand, Word users tend to use mainly the presentational markup (explicitly telling the block of text the font size, font family, weight, ...). Word allows the structural markup, but it is not forced too much.

Plain HTML is clearly structural, but the span and the like element allow to attach a lot of attributes to the block of text in the non-structural manner. You can clearly see the difference between the manually created HTML, technically generated HTML, and the documents converted from Word docs. Therefore, it may be difficult to find a common denominator even for HTML documents. The XML adds even more possibilities that can be misused.

But if you want to have one format that covers everything, then it probably should be XML. However, it may be one with document type designed by you for the purpose. The good thing is that there are tools for verification of your intermediate XML document. This way, you can be later sure that there is a way to the final form.

My guess is that it is almost impossible to convert various sources to the intermediate format with the good quality. It depends a lot on who created the souces. It is likely you will have to write a lot of parser for special subsets of the documents.

Python is probably a good choice. It depends on your knowledge. If you are better in Java or Perl, they can be better. I would prefer Python. (I do not have a good working knowlege of Java, and my Perl knowledge is rusty because I have found Python much better for me.)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.