More Than Word(s)

Ways to deal with MS Word documents using Linux and tocreate platform-independent documents.
Unconventional Words

All of the above-mentioned applications have various requirements: some rely heavily on pre-installed libraries (such as KWord), some are rather resource hungry (StarOffice/OpenOffice), others are expensive and/or not open sourced. However, all of them try to preserve a certain style or a certain way of formatting a document.

While this is certainly useful and important, I have found that I have no use whatsoever for a word processor, no matter which one. In 90% of the cases where some thoughtless person sends me a .doc file, the information contained within the document could have been communicated easily in plain text in a fraction of the file size.

So let's talk business now and see how we can extract the necessary information from proprietary file formats. There are a few tools worth mentioning, and their beauty lies in the fact that we do not even need X because they are all command-line tools.

antiword

antiword takes a Word document as input and extracts the information contained in it, converting it to plain ASCII text or to PostScript. It tries to maintain the formatting as much as possible, and it does a fairly decent job of it.

It's quick, and because it is a command-line tool, we can redirect the output to another process or file for further modification. To take a quick glance at the content of the file, you could pipe the output to less:

antiword HUGE.DOC | less

Or, if you'd rather have a hard copy:

antiword -p letter HUGE.DOC | lpr
I found antiword so useful that I replaced my previous mailcap-entry for handling of MS Word files (which I used to call abiword) with the following line:
application/msword;antiword %s | vim -
This allows me to read through .doc attachments from my mail reader (mutt), and since I pipe the output right into my favorite editor, I even can make modifications and save it to another file. Note that by placing this entry into my ~/.mailcap, all applications respecting this file will use antiword and vim to display .docs. If you are using a graphical browser such as Netscape, you might want to use a different editor or use the -g switch for vim to spawn a GUI front end.

If you are a hardcore minimalist, you will find that the command strings, part of the GNU binutils package, is often sufficient to extract the plain text information from a .doc file. However, antiword has the significant advantage over strings in that it can also extract images in addition to text.

For details on the use of the various options and on how to extract images from a Word file, see antiword at www.winfield.demon.nl/index.html.

wv

The other application, formerly known as mswordview and now available as wv, has been around for quite some time. When I first installed Red Hat 5.2 a few years ago, the Netscape browser used mswordview as the standard application to handle .doc files, as it converted them quite reliably into nice HTML. Note that I'm not talking about wordview, a Microsoft product. The similarity in the name caused the author to rename his tool.

While it certainly is great for a browser to use an application that turns Word files into HTML, this is not always the ideal output format. Therefore, wv now includes a whole set of tools to convert Word documents into a large variety of formats, including, but not limited to, ASCII text, HTML, LaTeX, PostScript and PDF. wv is published under the GPL and is available for free download.

No Words

So far we've seen how we can read Word documents and even what options there are to write documents that, in Winworld, would most likely be done in Word. But I can't help concluding that the word processor itself, as an application, is not required or is useless in the vast majority of cases.

The typical user trying to write a simple progress report, for example, usually follows a certain scheme: writes something, uses mouse to highlight the text, uses mouse to point and click and select bold, presses Return a number of times, presses Space a number of times, decides he/she doesn't like it, presses Delete a number of times, uses mouse to point and click and select italics, repeats.

I am fully aware that this is not the proper way to utilize a powerful word processor, but let's face it, that's exactly how the majority of users (those for whom these “user-friendly” applications are designed) work. The efforts required to enter a table of contents, a bibliography, cross-references, etc., can only be imagined.

Eventually, the outcome is a document that takes hours to prepare and that looks only the way it should on this platform using a particular version of this word processor. To avoid such bad practices, let's investigate some alternative methods for preparing platform-independent documents.

______________________

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState