msevior ([info]msevior) wrote,
@ 2005-12-30 11:03:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
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.


(16 comments) - (Post a new comment)


(Anonymous)
2005-12-30 02:44 am UTC (link)
I seriously did not know about AbiCommand. Sounds *really* useful though.

(Reply to this)

USEFUL 100%
(Anonymous)
2005-12-30 11:33 am UTC (link)
This is really useful, one of the best features I would say, it's like the com interface of ms word. Imagine, I just can code my billing application in pygtk or mono and when user wants to print the bill I open in the background my bill template with abicommand and replace special chars with name of client, company,etc, and print it, I would have also to show the user the preview before print. This technique is heavely used by windows programmers in their programs by using ms word...

(Reply to this)


(Anonymous)
2005-12-30 12:42 pm UTC (link)
this is a really great feature. is there the possibility to output a file in whatever format to .ps or directly to .pdf? i'm using openoffice.org for that but obviously is not suitable in a server environment, even in batch mode (and it requires an X server anyway afaik.

(Reply to this) (Thread)


(Anonymous)
2005-12-30 01:05 pm UTC (link)
This will for example output a MS Word file to a postscript file:

abiword --print=foo.ps foo.doc

Note that this does _not_ go through libgnomeprint, so the results might not be as good (at the moment our own, old printerdriver is used). We should fix that someday...

(Reply to this) (Parent)


(Anonymous)
2005-12-30 02:57 pm UTC (link)
about a decade ago, in a whimsical usenet discussion on one of the OS advocacy newsgroups, i suggested that building CLI applications with GUI interfaces on top of them was a smart thing to do. i even took this point far enough to suggest that building text-mode manipulable CAD applications might be useful and good. and people thought i was clearly crazy... now it's sounding like that might be next, for some programmer somewhere or other...

(Reply to this) (Thread)

Nice feat. for blind users
(Anonymous)
2006-01-08 07:29 pm UTC (link)
I'm blind so text-mode is mandatory under linux, and this plugin
sounds like a dream to me... I spend a lot of time getting down tons
of funky formatted documents and this would give me, at last, access
to a popular desktop word processor (antiword is nice but I can't
easily collaborate with sighted people on a single document). Join me
at debian-accessibility@lists.debian.org ML, there should be nice echo
to this feature there!

(Reply to this) (Parent)

AbiCommand support on windows ?
(Anonymous)
2006-01-16 01:29 pm UTC (link)
I saw this nice feature a while ago, but I didn't manage to use it under windows. Do you know if it works under this OS ?

(Reply to this) (Thread)

Re: AbiCommand support on windows ?
[info]msevior
2006-01-16 09:19 pm UTC (link)
Unfortunately no. It's unix only.

Martin

(Reply to this) (Parent)(Thread)

Re: AbiCommand support on windows ?
(Anonymous)
2006-02-01 05:43 pm UTC (link)
I just found out about AbiWord myself, and was jacked about the AbiCommand plugin. Now, when you say "unix only", doesn't (shouldn't?) that also include OS X? I haven't found any mention of the plugin for os x.

(Reply to this) (Parent)(Thread)

Re: AbiCommand support on windows ?
[info]msevior
2006-02-02 01:01 am UTC (link)
In principle it should be possible to add this feature for OSX (and Windows) given a sufficiently motivated developer. In practice someone who understands how OSX (or Windows) works needs to do a fair bit of grunt work to implement the xap_UnixNullGraphics.cpp class for these platforms.

We have two hardcore OSX developers hub and fjf but neither have shown much interest in this working for OSX.

As for myself I do not have the time or inclination (or the hardware!) to become an OSX hacker. If someone within the OSX development community would like to take the project I on, I would be more than happy to help them out and give them pointers.

Cheers

Martin

(Reply to this) (Parent)

Installation?
(Anonymous)
2007-02-10 06:16 am UTC (link)
I have a GoDaddy account with a linux server. They do not allow ssh. Can I still install abiword/abicommand and use it from php?

(Reply to this) (Thread)

Re: Installation?
[info]msevior
2007-02-10 01:06 pm UTC (link)
I would take that up with GoDaddy. Installing Abiword and it's dependencies without ssh would behard.

(Reply to this) (Parent)

DOC to PDF Conversion
(Anonymous)
2008-07-28 08:14 am UTC (link)
Hi,

It seems real cool stuff. I have a requirement to convert WORD files to PDF file. And i will do this from PHP so i need command line. Is this possible ? Also I want to brand the converted PDF with my page for example. Suppose i have a copyrighted messages which i want to put on first page. Please guide if that is possible. Also is it possible on shared server ?

Regards
Khan

(Reply to this) (Thread)

Re: DOC to PDF Conversion
[info]msevior
2008-07-28 12:00 pm UTC (link)
HI Khan,
Yes you can do all that.

Just script it and use abicommand to insert the taxt and pages you need. Remember it's all scriptable, That's the point of the feature.

Cheers

Martin

(Reply to this) (Parent)(Thread)

Re: DOC to PDF Conversion
(Anonymous)
2008-07-28 01:10 pm UTC (link)
Thanks mate. I will give it a try.

(Reply to this) (Parent)


[info]d3ad_w0rm
2009-07-27 01:48 pm UTC (link)
Hello! Nice tool.
Though, I couldn't manage to use it for my purpose (I need to trim document to 4 first pages).


load /path/to/document.doc
movept
selectstart
movept EOD
delete 1
save /path/to/newfile.doc


I'm not sure, if I did everything correct, but is it possible to navigate through the pages using movept command? I don't quite understand what movept options mean.



(Reply to this)


(16 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…