Page 1 of 1

Creating bookmarks

PostPosted: Mon May 10, 2010 6:01 am
by alla
I am trying to insert bookmarks in a document. As far as I understand a bookmark is represented by a <BookmarkStart/> and a <BookmarkEnd/> elements. This is how I create a bookmarkStart:
Code: Select all
        org.docx4j.wml.ObjectFactory factory = new org.docx4j.wml.ObjectFactory();
        org.docx4j.wml.CTBookmark bookmarkStart = factory.createCTBookmark();
        bookmarkStart.setName("something");


Unfortunately I can't figure out how to create a BookmarkEnd. Reading the forum I found this thread http://dev.plutext.org/forums/viewtopic.php?f=6&t=161&hilit=CTBookmark&sid=62b7ec089f118a4202d955b5dc51fff1 and though that perhaps BookmarkEnd is represented by org.docx4j.wml.CTMarkupRange. However when I insert a CTMarkupRange in the document I get an exception when I save it:

Code: Select all
19:46:44,001 ERROR org.docx4j.openpackaging.parts.JaxbXmlPart:182 [] javax.xml.bind.MarshalException
javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: unable to marshal type "org.docx4j.wml.CTMarkupRange" as an element because it is missing an @XmlRootElement annotation]
- with linked exception:
[com.sun.istack.SAXException2: unable to marshal type "org.docx4j.wml.CTMarkupRange" as an element because it is missing an @XmlRootElement annotation]


What am I doing wrong? Or rather, how should I do it right? :)

Re: Creating bookmarks

PostPosted: Sun Apr 24, 2011 2:08 pm
by jason
April 2011: I've deleted the previous replies.

See the BookmarkAdd sample for how to do this: http://dev.plutext.org/trac/docx4j/brow ... rkAdd.java

Re: Creating bookmarks

PostPosted: Sun Apr 24, 2011 11:33 pm
by smer4
yes thatks a lot, jason, that was my questions as well.
Do you know how to make the bookmark like this VISIBLE?
So the text whitch is in a bookmark looks like different?
Not from the common rpr styles but from the variables of bookmark?
Or is it possible to make the borders of bookmark visible?
Would be very thankfull for answer.