Comments on: Getting started with the API part II : some basic Writer operations Friends of Oracle and Java Fri, 06 Mar 2015 01:45:01 +0000 hourly 1 By: Phong Nguyen Fri, 25 Feb 2011 19:46:38 +0000 Could I export only the first page of a document?
Any help will be approcated.

By: martin joseph Fri, 20 Feb 2009 06:35:52 +0000 Hai Wouter van Reeven,

thanks for the reply …..
sorry for not being grateful enough .
i was able to insert bookmarks like i wanted .. thanks to your suggestion.

after i made my first post …. i kinda moved out of openoffice api and all …

but now i am desperately in need of your help.

I will describe my problem as clearly as i can.

I am making an application.. which needs to embed open office within java awt/swing application
This i was able to do using some Officebean without much lines of code .(i used the office bean directly without subclassing it)

For this i have an awt frame with a menu bar.
at click of a menuitem i added a panel with some buttons and also the officebean.

now what i want is , when i click one of those buttons in the panel a particular bookmark should be inserted
in the document in the officebean

the examples i came across which insert bookmarks dont use officebean. So i am in a dilemma.

Also i would want to be able to list out the bookmarks in the document in the officebean in a listbox outside the

sorry if i have confused you …
I would be very grateful if you could help in any way

By: site admin Thu, 27 Nov 2008 22:20:33 +0000 Hi Martin,

You should move the text cursor to the end first. By default the
cursor is at the start of the text. Please see my other code for how to
do this.



By: martin joseph Wed, 26 Nov 2008 09:55:18 +0000 hey Wouter van Reeven

thank you for the 2-part article ….though i found the developer’s guide had useful examples , i wasnt sure what the methods were meant to do and what the arguments were for ..Your article helped me a lot ..
now could u help me a bit more

i need to insert text into bookmarked fields of a template file . from ur code samples i was able to find the bookmarked fields …but i cant seem to understand how to insert text after the bookmarked field…

say i have bookmarks


i want to insert a name after the bookmarks like

doctor martin joseph
patient raju

but my code (not actually mine combination of samples from ur article and a few other examples) inserts the name
martin josephdoctor

the portion of the code i want to edit is

String b1=”Clinic “;

XTextRange textRange = null;
Object bmk=null;
XNameAccess bookmarkNames = bookmarksSupplier.getBookmarks();
bmk= bookmarkNames.getByName(b1);
XTextContent bookmarkContent = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, bmk);
textRange =bookmarkContent.getAnchor();
xText.insertString(textRange,”Santa Clara” , false);

where b1 is the first bookmark

By: babu Thu, 17 May 2007 21:49:15 +0000 I am converting html to pdf. i saved the following html file in my local drive. The First time i convert the file , it works perfectly but if i try it again on the same file, the last few pages are skipped, and when i restart my machine, again it will work perfectly the first time, however in the subsequent conversions the last few pages are skipped. I can send the code i am using
propertyValues[1].Name = “FilterName”;
propertyValues[1].Value = “writer_pdf_Export”; for output file storeToURl method
and i am using propertyValues[1].Name = “FilterName”; propertyValues[1].Value = “HTML (StarWriter)”; while opening the html file in the loadComponentFromURL method. help will be appreciated.

By: priyanka Wed, 07 Feb 2007 13:36:22 +0000 i am trying to wite a java program that opens a writer document and exports it to html….

XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, xComp);
PropertyValue[] storeProps = new PropertyValue[1];
storeProps[0] = new PropertyValue();
storeProps[0].Name = “FilterName”;
storeProps[0].Value = “HTML (StarWriter)”;

I have gone through all the sample code I could find, and I still get a…
i also want to save this code just as an Openoffice document ……it still gives the same exception …

plz help

By: Rajeev E Wed, 13 Dec 2006 14:41:08 +0000 Great, this article really did get me started with OOo Api. For a fortnight I tried deciphering the guide and well, wasted a whole lot of time. This does give the concepts so that I can put the delvelopers guide to good use
Thanks a lot

By: Christopher Smith (OopScope) Fri, 11 Aug 2006 23:38:17 +0000 Thanks. This helped a lot… the storeToUrl as opposed to storeAsUrl is key to the pdf export.

Unfortunately the OOo develper’s guide, while having a huge quantity of information, does not contain some of the essentials such as tables of PropertyValues for each method. The API documentation is sparse as well. I have yet to find one example that works as advertised without some trial and error.

Once things are working in OOo, however, they are fast and reliable in contrast to the MSOffice suite.

Two small utility methods that I add to my OO access classes or a util class are:

private PropertyValue newPropertyValue(String name, Object value) {
PropertyValue pv = new PropertyValue();
pv.Name = name;
pv.Value = value;
return pv;

private PropertyValue newPropertyValue(String name, boolean value) {
return newPropertyValue(name, new Boolean(value));

This condenses the propertyValue creation to a little more readable form:

PropertyValue[] storeProps = new PropertyValue[] {


By: Wouter van Reeven Mon, 26 Jun 2006 09:01:51 +0000 Hi Lucas,

Thanks. I didn’t put my presentation online yet as I got too much carried away writing these two articles. And I didn’t create a Powerpoint presentation, but an Impress presentation. I did convert it to Powerpoint and handed it over to the NL-JUG people during the conference so I suppose it will be put online there any time soon. Our next Knowledge Center session will be about OOo (if I’m not mistaken) so you’ll get to see my presentation there anyway.

Greets, Wouter

By: Lucas Jellema Mon, 26 Jun 2006 07:56:57 +0000 Wouter,

Great article and a very good way to get me started on using the OO API. This makes programmatic manipulation of high quality documents – and indirectly even Microsoft Office documents – a realistic option. The opportunities seem to be enormous.

Can we find the presentation you did on this for the NL-JUG conference on line somewhere? Did you really create your PowerPoint presentation for that session from Java?