I need to do the simple Program whcih need to extract text from image using Onenote Interop? Could any one suggest me the appropriate document for my concept please?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Text recognized by OneNote's OCR is stored in the one:OCRText element in the XML file structure in OneNote. e.g.
<one:Page ...>
...
<one:Image ...>
...
<one:OCRData lang="en-US">
<one:OCRText><![CDATA[This is some sampletext]]></one:OCRText>
</one:OCRData>
</one:Image>
</one:Page>
You can see this XML using a program called OMSPY (it shows you the XML behind OneNote pages) - http://blogs.msdn.com/b/johnguin/archive/2011/07/28/onenote-spy-omspy-for-onenote-2010.aspx
To extract the text you would use the OneNote COM interop (as you pointed out). e.g.
//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();
See the "Application Interface" docs on MSDN for more info - http://msdn.microsoft.com/en-us/library/gg649853.aspx