This sample appears to be out of date. Can you provide a new version of just the RtfStringToDocument(string rtf) method for Java?
Thanks for your inquiry. Please check the following RtfStringToDocument method. Hope this helps you.
private static Document RtfStringToDocument(String rtf) throws Exception
{
Document doc = null;
InputStream rtfStream = new ByteArrayInputStream(rtf.getBytes(StandardCharsets.UTF_8));
LoadOptions loadoptions = new LoadOptions();
loadoptions.setLoadFormat(LoadFormat.RTF);
doc = new Document(rtfStream, loadoptions);
return doc;
}