I may miss the right terms to query Google, so perhaps you can help me. I want to write a script which starts/ensures whatever wordprocessor, creates a new document from a given $TEMPLATE, fills the address lines for a given $CONTACT, and sets the cursor right behind the “Dear Sir/Madam,”. $CONTACT may be the UID from KABC or just some already preformatted address string.
Is this possible with Openwriter or, better, KWord? Are there already similar examples?
Thanks, if only for the right query terms

For OpenOffice.org: look into the OpenOffice.org developer book. OpenOffice.org is controllable remotely via the UNO component API in the language of your choice: java, C++, python, rexx, basic …
I don’t however not know if the same is possible with KWord. It might be possible with KWord+DCOP. Let me know if you find something!
Greetings,
Daniel
Comment by Daniel Beck — June 12, 2007 @ 6:24 pm |
Save your template use as variables e.g
@first_name@, @last_name@, @place@, etc
The script may look like:
# cp template.odt letter.odt
# unzip -p letter.odt content.xml > content.xml
# sed -i ’s/@variables@/value/g’ content.xml
# zip letter.odt content.xml
# kword letter.odt
This works quite nice!
Comment by RB — June 12, 2007 @ 6:52 pm |
Are you interested in something like “Generating Kexi reports using OpenOffice.org Writer”?
Polish screencast:
http://www.kexi.pl/media/raporty/
Comment by jstaniek — June 12, 2007 @ 7:03 pm |
PS: filling the template is performed using ODF variables;
example template: http://www.kexi.pl/media/raporty/korespondencja.odt
resulting document:
http://www.kexi.pl/media/raporty/korespondencja.pdf
Comment by jstaniek — June 12, 2007 @ 7:05 pm |
Thanks for your comments.
@RB: Hm, nice idea
My problem with it is that it won’t work so easily when “value” has linefeeds in it, like with multiline addresses (KABC has a nice call “formattedAddress()”).
@jstaniek: kexi2odt.exe looks similar to what I want. But then all I want to do is to fill some variables/field, using the editor that has already opened it. Using another, third program that can parse and edit odt files only blows things up IMHO.
Meanwhile I found that using the DCOP call “setCustomVariableValue(String,String)” might get me close to my target, if only limiting me to KWord. But hey, OOo users are free to send something that only works with OOwriter.
Looks like I found a way to go which is sufficient for prototyping…
Comment by frinring — June 14, 2007 @ 3:53 pm |