Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert word (.docx) to docbook

I have been tasked to find a way to convert a large amount of .docx files to docbook 5. Currently, we open the file in openoffice and save to docbook. This is a time consuming task, but I am confident there is a better way. These files will then be processed further to our custom relax NG schema. Therefore this conversion does not need to be flawless. I have looked around, and will continue to investigate some leads, but have not found anything usefull.

looking at Convert doc/docx to semantic HTML they have suggested upCast, but this does not seem appropriate to my needs.

I am looking for something freely available that I can use from the command line. I ultimately I would like to batch process our files. I have included the linux, python, and java tags for these are the environments I am most comfortable, but would be willing to bend for the right solution. I am trying to do some research before I go out and reinvent the wheel.

like image 743
matchew Avatar asked Jun 13 '11 15:06

matchew


3 Answers

At the risk of earning an archeologist's badge from SX, the answers should include a reference to Pandoc. This does not rely on open office.

pandoc -f docx -t docbook -o newdocbook.dbk --standalone original.docx

like image 101
intotecho Avatar answered Oct 19 '22 09:10

intotecho


There are several ways to script this, both using external scripts and scripts within OpenOffice. See the following links for some examples:

  • http://juretta.com/log/2006/08/10/convert_microsoft_word_to_docbook_xml_using_ruby_and_openoffice/
  • http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html
  • http://www.xml.com/pub/a/2006/01/11/from-microsoft-to-openoffice.html
  • http://mail.python.org/pipermail/python-announce-list/2006-May/004951.html
  • http://dag.wieers.com/home-made/unoconv/

Some of the above links aren't using Java or Python, but the principles still apply and the scripts are typically short enough that they can be ported (the first example is in Ruby, but it's my personal favorite due to the simplicity).

like image 24
bta Avatar answered Oct 19 '22 08:10

bta


You can run openoffice in server mode and feed the docs to it without having to manually open each on.

One way: http://code.google.com/p/bungeni-editor/wiki/RunningTheJODConverterServer

like image 3
jlargent Avatar answered Oct 19 '22 08:10

jlargent