AbiCommand

From AbiWiki

(Difference between revisions)
Jump to: navigation, search
(Currently Implemented Commands)
(Currently Implemented Commands)
Line 44: Line 44:
The complete list of AbiCommand's follows. This list of commands is easy to extend.
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
-
  * Currently implemented commands are...
+
* quit - exits the program
-
  * help - prints this message
+
* new - create a new empty document.
-
  * quit - exits the program
+
* load "filename" - load "filename" replacing the current document.
-
  * new - create a new empty document.
+
* printfile "filename1" "filename2"... - print the current document into the filenames listed.
-
  * load "filename" - load "filename" replacing the current document.
+
* replaceall "find" "target" - replace every occurance of "find" with "target" in the current document.
-
  * printfile "filename1" "filename2"... - print the current document into the filenames listed.
+
* replacenext "find" "target" - replace the next occurance of "find" with "target" in the current document.
-
  * replaceall "find" "target" - replace every occurance of "find" with "target" in the current document.
+
* inserttext "target" - Insert "target" at the current point in the document.
-
  * replacenext "find" "target" - replace the next occurance of "find" with "target" in the current document.
+
* delete "args" - Delete "args" characters at the current point in the document.
-
  * inserttext "target" - Insert "target" at the current point in the document.
+
* replacenext "find" "target" - replace the next occurance of "find" with "target" in the current document.
-
  * delete "args" - Delete "args" characters at the current point in the document.
+
* movept "arg" - Move the current point to another location in the current document.
-
  * replacenext "find" "target" - replace the next occurance of "find" with "target" in the current document.
+
*; options for arg are: BOD,EOD,BOP,EOP,BOS,EOS,BOL,EOL,BOW,+num,-num,num
-
  * movept "arg" - Move the current point to another location in the current document.
+
* selectstart - Start a selection at the current point
-
      options for arg are: BOD,EOD,BOP,EOP,BOS,EOS,BOL,EOL,BOW,+num,-num,num
+
* selectclear - Clear the current selection.
-
  * selectstart - Start a selection at the current point
+
* findnext "target" - Find the next occurance of target and select it.
-
  * selectclear - Clear the current selection.
+
* save "filename" - Save the current document.
-
  * findnext "target" - Find the next occurance of target and select it.
+
*; If filename is omitted the file is saved to it's original name
-
  * save "filename" - Save the current document.
+
*; Otherwise the extension of the filename is used to determine the format of the file
-
      If filename is omitted the file is saved to it's original name
+
* converttotext "src" "dest" - convert the file given in "src" to the plain text file named "dest"
-
      Otherwise the extension of the filename is used to determine the format of the file
+
* convert <src> <dest> <type> - Convert the file given in <src> to the file named <dest>.  
-
  * converttotext "src" "dest" - convert the file given in "src" to the plain text file named "dest"
+
*; The type of conversion is given by the third parameter (abw,html,odt, etc.).
-
  * convert <src> <dest> <type> - Convert the file given in <src> to the file named <dest>.  
+
* writepid "file" - write the PID of this process to the file "file"
-
      The type of conversion is given by the third parameter (abw,html,odt, etc.).
+
* server "error file" - This is being run as remote process. Write an error file on error.
-
  * writepid "file" - write the PID of this process to the file "file"
+
* previewpng Document preview.png width height  
-
  * server "error file" - This is being run as remote process. Write an error file on error.
+
*; Create a PNG preview of Document with name preview.png of width pixels wide and height pixels in height.
-
  * previewpng Document preview.png width height  
+
* visualedit - popup a visual window and edit the file or just preview what you've done. Close the window when finished.
-
      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.
+

Revision as of 04:19, 17 April 2008

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.

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 --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.

  • 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"
  • 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