Hi Svante,

thx for replying, I appreciate.
My approach is different. I'm creating odf file from the scratch in Java code. Let me clarify:

1.

/TextDocument outputOdt = TextDocument.newTextDocument();/
/Paragraph paragraph = outputOdt.addParagraph("First ");//
//paragraph.appendTextContent("Second ");//
//paragraph.appendTextContent("Third");/


Here, I want only word "Second" (all words are in one line - like sentence) to be bold font. I can find in API only:
/paragraph.setFont(/ /new Font("Arial", BOLD, 10));/
- but this one will set the whole paragraph to bold:(

2.
Also hyperlink, like:
/p2.appendHyperlink("Hello", new URI("http://...";));///does not seems to 
"support" font settings.
But I think if I get to know how to fix my first problem, this hyperlink 
problem will be gone, too.

Thanks for any kind of reply.

 Peto

On 03/01/2016 09:23 PM, Svante Schubert wrote:
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