From AbiWiki

Jump to: navigation, search



AbiWord has an extensive array of command line options, and many people found these useful. However each use of Abiword from the command line required reloading Abiword into memory, which was highly inefficient. Instead you can use the command line interface to AbiWord.

This is a plugin, ("AbiCommand"), which is invoked with the command line

abiword --plugin AbiCommand

The "--plugin" means execute following the plugin immediately.

AbiCommand provides a command line interface into AbiWord which allows all sorts of interesting things. You can load and save documents. You can find and replace text. Insert text, delete text etc.

After the release of Abiword-2.4 we began to get more and more bug reports and Requests For Enhancements for AbiCommand. It appears that some people have realized how useful this is for document conversion.

New in version 2.6

As of version 2.6, AbiCommand only works on Unix-like systems (not windows), however it doesn't require a running X11 system so it can be used in an headless server environment.

AbiWord now has very good support for export to odt format as well as xsl-FO, which joins our great support for export to HTML, RTF and ABW. We also had a report that showed how easy this was to utilize with PHP..

PHP Example

  $handle = popen("/usr/local/bin/abiword --plugin AbiCommand 2>&1", "w");
  fwrite($handle, "server /tmp/abiword_errors \n");
  fwrite($handle, "load /usr/local/apache/sites/Toronto.doc \n");
  fwrite($handle, "save /tmp/toronto1.html \n");

or via the "converttotext" or "converttohtml" commands in AbiCommand

So any of you admins wishing to display Word Processor docs in users webbrowsers, just employ some combination of PHP scripts and AbiWord and you're done!

If you are administrator who wants to automatically convert legacy documents in MS *.doc formats to a more modern and maintainable format (like *.abw or *.odt) go to it :-)

C code example

Martin Sevior wrote some code in C to open a remote abiword process for document processing. You can copy and paste code from this to get ideas on how to do your own document processing.

Source code



Currently Implemented Commands

The complete list of AbiCommand's commands follows:

  • help - prints this message
  • quit - exits the program
  • new - create a new empty document.
  • load "filename" - load "filename" replacing the current document.
  • printfile "filename1" "filename2"... - print the current document into the filenames listed.
  • replaceall "find" "target" - replace every occurance of "find" with "target" in the current document.
  • replacenext "find" "target" - replace the next occurance of "find" with "target" in the current document.
  • inserttext "target" - Insert "target" at the current point in the document.
  • delete "args" - Delete "args" characters at the current point in the document.
  • replacenext "find" "target" - replace the next occurance of "find" with "target" in the current document.
  • movept "arg" - Move the current point to another location in the current document.
    options for arg are
  • selectstart - Start a selection at the current point
  • selectclear - Clear the current selection.
  • findnext "target" - Find the next occurance of target and select it.
  • save "filename" - Save the current document.
    If filename is omitted the file is saved to it's original name
    Otherwise the extension of the filename is used to determine the format of the file
  • converttotext "src" "dest" - convert the file given in "src" to the plain text file named "dest"
  • convert <src> <dest> <type> - Convert the file given in <src> to the file named <dest>.
    The type of conversion is given by the third parameter (abw,html,odt, etc.).
  • writepid "file" - write the PID of this process to the file "file"
  • server "error file" - This is being run as remote process. Write an error file on error.
  • previewpng Document preview.png width height
    Create a PNG preview of Document with name preview.png of width pixels wide and height pixels in height.
  • visualedit - popup a visual window and edit the file or just preview what you've done. Close the window when finished.
Personal tools