Question

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)?

Was it helpful?

Solution

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).

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top