Im trying to convert HTMl Rich Text to a String that is compatible with Office, im exporting in an excel, but i want to set this text into a cell, so exporting as a doc is not exactly what i need.
These are the examples a looked, i need the String, so im trying to get the data as String. But export as RTF is not supported.
InputStream targetStream = new FileInputStream(new File("C:\\AsposeTest\\" + "in.html"));
Document doc = new Document(targetStream);
RtfSaveOptions rtfSaveOptions = new RtfSaveOptions();
rtfSaveOptions.setExportCompactSize(true);
rtfSaveOptions.setExportImagesForOldReaders(false);
rtfSaveOptions.setSaveFormat(SaveFormat.RTF);
doc.save("C:\\AsposeTest\\" + "rtf.rtf", rtfSaveOptions);
String temp = doc.getParentNode().toString(SaveFormat.RTF);
if (temp != null) {
System.out.println("RTF content generated successfully.");
} else {
System.out.println("Failed to generate RTF content.");
}
Error im getting:
Exception in thread "main" java.lang.IllegalStateException: Exporting fragments of a document in this format is not supported.
at com.aspose.words.zzCP.zzZ(Unknown Source)
at com.aspose.words.Node.toString(Unknown Source)
in.7z (473 Bytes)