Hi everyone,

Is it possible to insert html into a styled document using
the rtf editor kit?

If it is possible could someone show me a simple example of
how this is done

Yours Sincerely

Richard West

Haven't tested, this is just a guess. I don't know if an rtf document will display html as plain text or not, but you can try.

String html = "<b>hello world</b>";
Reader reader = new StringReader(html);
RTFEditorKit.read(reader, document, pos);

rtf wouldn't understand html tags, instead consider them to be normal flat text (unless a specific html tag would happen to also be an rtf tag (in which case it would almost certainly be something completely different) in which case you'd likely end up with corrupted rtf.

The rtf editor kit is not meant for html, you're going to have to write something that parses html and uses the results of the parser to send commands to your rtf editor.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.