Hello Peter,

it is possible to search text content by a certain style, but I am
uncertain if this is your request and might come not out-of-the-box.
If you are aware of the content, let's think of your paragraph example of
containing three words:"First second third".
Where the word "second" is bold and should get a reference, you could solve
it with the simple API as follows, written as a test and tested by myself:

@Test
public void insertHyperlink() throws Exception {
    TextDocument testDoc = (TextDocument)
Document.loadDocument(ResourceUtilities.getAbsolutePath("threeWords-middleBold.odt"));
    search = new TextNavigation("second", testDoc);
    while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        item.addHref(new URL("http://www.heise.de";));
    }
    testDoc.save(ResourceUtilities.newTestOutputFile("_newHyperlink.odt"));
}

Hope this is what you need,
Svante

On Sun, Feb 28, 2016 at 6:56 PM, Peter Cernocky <[email protected]> wrote:

>  Hi guys,
>
>  I have been googling this for quite a long time. I can not understand,
> how to make in Java these examples:
>
> 1. to have one sentence (paragraph) inside which is first word with
> "normal" font, second word "bold" font and third word again with "normal"
> font
> 2. how to insert into paragraph url link, which has bold font.
>
>  I found some examples here: incubator.apache.org/odftoolkit/simple/demo/
> - but no one mentioned these.
>
>  Thank you!
>
>  Peter
>

Reply via email to