msevior (msevior) wrote,

Server-side AbiWord

AbiWord's primary purpose is to be easiest way possible to prepare documents. We're very tightly focused on being as easy to use as possible. I'm particularly proud of our Visual Drag and Drop feature which substantially reduces a users need to use the clipboard.

However about 3 years ago I thought about the possibilities of utilizing all the neat features of AbiWord remotely. While AbiWord has an extensive array of command-line options, and many people found these useful, each use of Abiword from the command line required reloading Abiword into memory, which was highly inefficient. So I came up the idea of 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.

I thought this was a great idea but nobody seemed to be using it much. It was one of those "secret tips" computer magazines like to tell their readers about. Except nobody seemed to know about it.

Then 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. AbiWord-2.4.2 (due Real Soon Now) has very good support for export to odt format (Thanks Nokia!), 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..


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

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 :-)

The complete list of AbiCommand's follows. This list of commands is easy to extend.

AbiWord:> help

Currently implemented commands are...

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: BOD,EOD,BOP,EOP,BOS,EOS,BOL,EOL,BOW,+num,-num,num

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"

converttohtml "src" "dest" - convert the file given in "src" to the html file named "dest"

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.
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 15 comments