读取包含OLE嵌入式对象的RTF文件 [英] Reading RTF File Containing an OLE Embedded Object

查看:357
本文介绍了读取包含OLE嵌入式对象的RTF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

Question :

我需要读取一个包含OLE对象作为内部文档的RTF文件.

I need to read an RTF File that contains an OLE Object as innerdocument.

RTF文件= [Ole对象(Word文档)已嵌入其中.]

RTF File = [ Ole object (word document) is embedded into it.]

对包含单词(如OLE嵌入)的RTF文件进行采样.

我已经完成的参考:

  1. 在RTF中作为图像使用OLE

他们在这里完成了一个程序,用于提取以OLE形式嵌入到RTF中的图像.

Here they have done a program to extract the image embedded as OLE in RTF.

我已经提取了标记为正确答案的程序,但是它对我不起作用.

I had extracted the program which is marked as correct answer , but its does not work for me.

  1. 使用OpenXML SDK. (它无法打开RTF文件.)

  1. Using OpenXML SDK. (it cannot be able to open RTF Files.)

一些其他SDK,例如GemBox等.它们无法打开innerdocument. RTF中的ole)

some other SDK like GemBox etc.. Which cannot be able to open innerdocument ie. ole in RTF)

我已经完成的工作:

我已经使用了 microsoft.office.interop.word.dll 了,它给出了准确的答案,但是在服务器上不起作用.

I had done using microsoft.office.interop.word.dll which gives an accurate answer , but it will not work on server.

例如:它将使用MS WORD打开RTF文件,并将其安装在没有在服务器中安装WORD APPLICATION的客户端计算机中.

For eg: it opens an RTF File using MS WORD and which is installed in client machine where there is no WORD APPLICATION Installed in server.

所以,这不适合我.

我需要打开并阅读RTF OLE内容,并且需要存储在字符串中(例如,例如).用字符串bcoz我可以做很多事情.

I need to open and read the RTF OLE Content and i need to store in a string(say for eg). bcoz with string i can do lot of things.

任何人都可以解决我的问题吗??

Can anyone has an idea to solve my issue.?

推荐答案

请使用以下代码示例从RTF中提取OLE对象(Word文档)并将其导入到Aspose.Words的DOM中以读取其内容.希望对您有帮助.

Please use the following code example to extract the OLE object (Word document) from RTF and import it into Aspose.Words’ DOM to read its content. Hope this helps you.

Document doc = new Document(MyDir + "SAMPLE.rtf");

Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
if (shape.OleFormat != null)
{
    //Save the document to disk.
    shape.OleFormat.Save(MyDir + "output" + shape.OleFormat.SuggestedExtension);

    if (shape.OleFormat.SuggestedExtension == ".docx")
    {
        //Import the .docx ole object into Aspose.Words' DOM
        Document ole = new Document(MyDir + "output" + shape.OleFormat.SuggestedExtension);
        Console.WriteLine(ole.ToString(SaveFormat.Text));
    }

}

我与Aspose一起担任开发人员推广人员.

I work with Aspose as Developer Evangelist.

这篇关于读取包含OLE嵌入式对象的RTF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆