【发布时间】:2011-08-27 06:04:19
【问题描述】:
我需要做一个简单的程序,需要使用 Onenote Interop 从图像中提取文本?谁能建议我适合我的概念的文件?
【问题讨论】:
标签: c# office-interop onenote
我需要做一个简单的程序,需要使用 Onenote Interop 从图像中提取文本?谁能建议我适合我的概念的文件?
【问题讨论】:
标签: c# office-interop onenote
OneNote 的 OCR 识别的文本存储在 OneNote 中 XML 文件结构中的 one:OCRText 元素中。例如
<one:Page ...>
...
<one:Image ...>
...
<one:OCRData lang="en-US">
<one:OCRText><![CDATA[This is some sampletext]]></one:OCRText>
</one:OCRData>
</one:Image>
</one:Page>
您可以使用名为 OMSPY 的程序查看此 XML(它向您显示 OneNote 页面背后的 XML)-http://blogs.msdn.com/b/johnguin/archive/2011/07/28/onenote-spy-omspy-for-onenote-2010.aspx
要提取文本,您将使用 OneNote COM 互操作(正如您所指出的)。例如
//Instantialize OneNote
ApplicationClass onApp = new ApplicationClass();
//Get the XMl from the selected page
string xml = "";
onApp.GetPageContent("put the page id here", out xml);
//Put it into an XML document (from System.XML.Linq)
XDocument xDoc = XDocument.Parse(xml);
//OneNote's Namespace - for OneNote 2010
XNamespace one = "http://schemas.microsoft.com/office/onenote/2010/onenote";
//Get all the OCRText from the page
string[] OCRText = xDoc.Descendants(one + "OCRText").Select(x => x.Value).ToArray();
有关更多信息,请参阅 MSDN 上的“应用程序接口”文档 - http://msdn.microsoft.com/en-us/library/gg649853.aspx
【讨论】: