4

Lets see at this example:

  1. I've got HTML tagged text:

    <font size="100">Example text</font>
    
  2. I have *.odt (OpenDocument Text) document where I want to place this HTML text with formatting depends on HTML tags (in this example font tag should be ommited and text Example text should have 100point size font in result *.odt file).

I prefer (but this is not strong requirement) to use OpenOffice UNO API for Java to achieve that. Is there any way to inject this HTML text into body of *.odt document with simple UNO API build-in HTML-odt converter or something like this (or I have to manually go through HTML tags in text and then use OO UNO API for placing text with specific formatting - e.g. font size)?

Arek Woźniak
  • 695
  • 3
  • 12
  • 25

2 Answers2

4

OK, this is what I've done to achieve this (using OpenOffice UNO Api with JAVA):

  1. Load odt document where we want to place HTML text.
  2. Goto place where you want to place HTML text.
  3. Save HTML text in temp file in the system (maybe it is possible without saving with http URL but I wasn't testing it).
  4. Insert HTML into odt following this instructions and passing URL to temp HTML file (remember about converting system path to OO path).
Arek Woźniak
  • 695
  • 3
  • 12
  • 25
0

Maybe you can use JODConverter or you can use the xslt from xhtml2odt

Nickmancol
  • 1,034
  • 7
  • 16
  • 1
    Thanks for reply. I know what you mean - convert whole HTML document to ODT file, but this is not what I want to achieve - I want to convert HTML document and write it in specific place (in marked paragraph or something like this) in existing (containing other ODT text data) ODT file. – Arek Woźniak Nov 05 '12 at 13:47
  • Well, you can convert the whole html into odt and combine it to a previous odt file using ODFToolkit http://incubator.apache.org/odftoolkit/ simple API – Nickmancol Nov 05 '12 at 15:25
  • Yes, this is some option. If I won't find any other solution, then I will consider yours. Thanks for help. – Arek Woźniak Nov 05 '12 at 15:45