AbiCommand

From AbiWiki

Revision as of 02:13, 17 April 2008 by MartinSevior (Talk | contribs)
Jump to: navigation, search

Contents

AbiCommand

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. AbiWord now has very good support for export to odt format, 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 --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 :-)

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

ConvertToText.c

ConvertToText.h

Currently Implemented Commands

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.

Personal tools