Reputation: 49
I am trying to convert RTF to PTF using Swing's RTFEditorKit
. This is my code.
Example RTF content is -
<p>4th Review Information for Bug Id DRRaa50524 </p>
<h5 style="text-align: center;">4th Review Information for Bug Id DRRaa50524</h5>
<h2 style="text-align: right;">4th Review Information for Bug Id DRRaa50524</h2>
But I am getting document length as 0 and text as empty. What is wrong with my code?
public String RTFToPTConverter(String des) throws Exception {
RTFEditorKit rtfParser = new RTFEditorKit();
Document document = rtfParser.createDefaultDocument();
rtfParser.read(new ByteArrayInputStream(des.getBytes()), document, 0);
System.out.println(document.getLength());
String text = document.getText(0, document.getLength());
System.out.println(text);
return text;
}
Upvotes: 0
Views: 1538