Extract embedded files from MS Rich Text Format rtf

Hi,

I am wondering if Aspose have APIs for extraction of embedded data from rtf.
In our company we have rtf files with embedded zip, txt, xml, docx and etc. documents in them and we are searching Java library to extract these files.


Hi there,

Thanks for your inquiry. OleFormat class provides access to the data of an OLE object. Please use OleFormat.save method to save embedded object as shown in following code example. Hope this helps you.

Document srcDoc = new Document(MyDir + "in.rtf");

NodeCollection shapes = srcDoc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : shapes)
{
    if (shape.getOleFormat() != null)
    {
        shape.getOleFormat().save(MyDir + "output" + shape.getOleFormat().getSuggestedExtension());
    }
}