Inserting inkdrawing that is searchable

P

Philipp Schmid

I am programmatically insert ink into a OneNote page using the code below.
The inkdrawing object is properly rendered in the requested page. However,
the ink is not searchable and the context menu has the 'Convert Handwriting
to Text' item grayed out. I am setting isUnclassified to true which should
make the inserted ink searchable, but that doesn't seem to be the case. Is
there another step that I need to perform to get this to work? Note that if I
draw on the same page using the mouse I can create searchable ink just fine
and furthermore the page content contains appropriate InkWord objects.

Main code:

string textContent = CreateText(pageId); // see below
Validate(textContent); // no validation errors

_app.UpdatePageContent(textContent, DateTime.MinValue);


and code that creates the XML:

private string CreateText(string pageId)
{
string resultString;
using (StringWriter stringWriter = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
{
string pageGUID = pageId.Substring(0, pageId.Length - 7);
string pagePath = @"Projects\Economica.one";

writer.WriteStartElement("one:page");
writer.WriteAttributeString("xmlns:eek:ne",
@"http://schemas.microsoft.com/office/onenote/2007/onenote");
writer.WriteAttributeString("ID", pageId);

writer.WriteStartElement("one:InkDrawing");
writer.WriteAttributeString("isUnclassified", "true");
writer.WriteAttributeString("inkOriginX", "0");
writer.WriteAttributeString("inkOriginY", "0");

writer.WriteStartElement("one:ShapeInfo");
writer.WriteStartElement("one:AnchorPoint");
writer.WriteAttributeString("x", "120");
writer.WriteAttributeString("y", "160");
writer.WriteEndElement(); // - one:AnchorPoint
writer.WriteEndElement(); // - one:ShapeInfo

writer.WriteStartElement("one:Data");
writer.WriteCData(GetSampleData());
writer.WriteEndElement(); // - one:Data

writer.WriteEndElement(); // - one:InkDrawing
writer.WriteEndElement(); // - one:page
}
resultString = stringWriter.ToString();
}
return resultString;
}

which creates the following XML string:

- <one:page
xmlns:eek:ne="http://schemas.microsoft.com/office/onenote/2007/onenote"
ID="{6A46FB6A-8A90-4D90-B87F-E998E4C5E95E}{1}{B0}">
- <one:InkDrawing isUnclassified="true" inkOriginX="0" inkOriginY="0">
- <one:ShapeInfo>
<one:AnchorPoint x="120" y="160" />
</one:ShapeInfo>
- <one:Data>
- <![CDATA[
AOUFHQTmAYYBAXAqABofi0JwRYR1gL7QRdkEWM9UiuaXxU+PBvi60uGbIr/scczMIrFBiQ67Eyzu
eqHeuxOL5V6zSJyboSVat1ES+oeVMvLsF0G4wBa/8yv0ekVTgCx6GNVEmWVKNAYxWzMUlUCeksyY
S7VqkBwSxVpVAxBIFESAgPwHRTJGMlcNAAAABQYLZU9mZ2gZFDIIAIAUAnaM4kEzCACAEALa7OJB
Eauq00FkAxVGAEBKGDapo08wFTlp5gOmjTzALdPLTzAdOWnmAABPCQRqAxVGAEBpED6ARSgAABXU
AAHi8AAaygAACmVRgv4CE/gIVYLALAAAAAAsAAASksqC/gIr+Ai5UsqWWUlllhYsssWWWLLLLFll
gWWWKllligo/QCNLQT3MF+A44AkEEgARIB9NL142b/RKtMpCz+i/yv4FFEYAQAAABRRGAEAAAApO
IIL+ATP4BNuWXNxcEKVZVTSC/gIb+AhyUAAAs3LACj9AIhmBSSQX4DjgCQQSABEg+fZC1Mry4Uug
gWCjX05u/QUURgBAAAAFFEYAgAAACp0BwgGC/gKD+AoQAFgWAAAAlGaliykWLKlibLmgAACUBKll
zZLDctlAWBYAAAAAAACC/gJL+Ak5ZcqIzU3Ksqi1LYtgLlECUlSwlli5RNgBNixZZYqUlllAbFlE
WJUqWVLLFRBFhSVNk2RubLNJoAoAESBgl3QpfkHHAQkEEgARIFmPLk5Sfg1ArcB74/ROTZkFFEYA
QAAABRRGAMAAAAppR4L+BJP4Enm5ZSwlipYWAiUiW52Xcs3Nlm5UXBYAgv4C4/gLlYssACVLLLFi
bLlLKllliiLFqWWACgARIMCS/ip+QccBCQQSABEgJH31egB1nEGgY21wrQc+1AUURgBAAAAFFEYB
AAAACjcBCX6ACWuACgARIMCf4St+QccBCQQSABEgS1aTMddqgkeQgsJk3d9xIAUURgBAAAAFFEYBQAAA
]]>
</one:Data>
</one:InkDrawing>
</one:page>


Any help would be much appreciated!

-- Philipp Schmid - Adapx
 
L

Lin

Can you convert ink that you write directly to OneNote? If you have desktop
OS instead of tablet OS, handwriting recognizer is not installed by default.

-Lin (MS)

Philipp Schmid said:
I am programmatically insert ink into a OneNote page using the code below.
The inkdrawing object is properly rendered in the requested page. However,
the ink is not searchable and the context menu has the 'Convert Handwriting
to Text' item grayed out. I am setting isUnclassified to true which should
make the inserted ink searchable, but that doesn't seem to be the case. Is
there another step that I need to perform to get this to work? Note that if I
draw on the same page using the mouse I can create searchable ink just fine
and furthermore the page content contains appropriate InkWord objects.

Main code:

string textContent = CreateText(pageId); // see below
Validate(textContent); // no validation errors

_app.UpdatePageContent(textContent, DateTime.MinValue);


and code that creates the XML:

private string CreateText(string pageId)
{
string resultString;
using (StringWriter stringWriter = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
{
string pageGUID = pageId.Substring(0, pageId.Length - 7);
string pagePath = @"Projects\Economica.one";

writer.WriteStartElement("one:page");
writer.WriteAttributeString("xmlns:eek:ne",
@"http://schemas.microsoft.com/office/onenote/2007/onenote");
writer.WriteAttributeString("ID", pageId);

writer.WriteStartElement("one:InkDrawing");
writer.WriteAttributeString("isUnclassified", "true");
writer.WriteAttributeString("inkOriginX", "0");
writer.WriteAttributeString("inkOriginY", "0");

writer.WriteStartElement("one:ShapeInfo");
writer.WriteStartElement("one:AnchorPoint");
writer.WriteAttributeString("x", "120");
writer.WriteAttributeString("y", "160");
writer.WriteEndElement(); // - one:AnchorPoint
writer.WriteEndElement(); // - one:ShapeInfo

writer.WriteStartElement("one:Data");
writer.WriteCData(GetSampleData());
writer.WriteEndElement(); // - one:Data

writer.WriteEndElement(); // - one:InkDrawing
writer.WriteEndElement(); // - one:page
}
resultString = stringWriter.ToString();
}
return resultString;
}

which creates the following XML string:

- <one:page
xmlns:eek:ne="http://schemas.microsoft.com/office/onenote/2007/onenote"
ID="{6A46FB6A-8A90-4D90-B87F-E998E4C5E95E}{1}{B0}">
- <one:InkDrawing isUnclassified="true" inkOriginX="0" inkOriginY="0">
- <one:ShapeInfo>
<one:AnchorPoint x="120" y="160" />
</one:ShapeInfo>
- <one:Data>
- <![CDATA[
AOUFHQTmAYYBAXAqABofi0JwRYR1gL7QRdkEWM9UiuaXxU+PBvi60uGbIr/scczMIrFBiQ67Eyzu
eqHeuxOL5V6zSJyboSVat1ES+oeVMvLsF0G4wBa/8yv0ekVTgCx6GNVEmWVKNAYxWzMUlUCeksyY
S7VqkBwSxVpVAxBIFESAgPwHRTJGMlcNAAAABQYLZU9mZ2gZFDIIAIAUAnaM4kEzCACAEALa7OJB
Eauq00FkAxVGAEBKGDapo08wFTlp5gOmjTzALdPLTzAdOWnmAABPCQRqAxVGAEBpED6ARSgAABXU
AAHi8AAaygAACmVRgv4CE/gIVYLALAAAAAAsAAASksqC/gIr+Ai5UsqWWUlllhYsssWWWLLLLFll
gWWWKllligo/QCNLQT3MF+A44AkEEgARIB9NL142b/RKtMpCz+i/yv4FFEYAQAAABRRGAEAAAApO
IIL+ATP4BNuWXNxcEKVZVTSC/gIb+AhyUAAAs3LACj9AIhmBSSQX4DjgCQQSABEg+fZC1Mry4Uug
gWCjX05u/QUURgBAAAAFFEYAgAAACp0BwgGC/gKD+AoQAFgWAAAAlGaliykWLKlibLmgAACUBKll
zZLDctlAWBYAAAAAAACC/gJL+Ak5ZcqIzU3Ksqi1LYtgLlECUlSwlli5RNgBNixZZYqUlllAbFlE
WJUqWVLLFRBFhSVNk2RubLNJoAoAESBgl3QpfkHHAQkEEgARIFmPLk5Sfg1ArcB74/ROTZkFFEYA
QAAABRRGAMAAAAppR4L+BJP4Enm5ZSwlipYWAiUiW52Xcs3Nlm5UXBYAgv4C4/gLlYssACVLLLFi
bLlLKllliiLFqWWACgARIMCS/ip+QccBCQQSABEgJH31egB1nEGgY21wrQc+1AUURgBAAAAFFEYB
AAAACjcBCX6ACWuACgARIMCf4St+QccBCQQSABEgS1aTMddqgkeQgsJk3d9xIAUURgBAAAAFFEYBQAAA
]]>
</one:Data>
</one:InkDrawing>
</one:page>


Any help would be much appreciated!

-- Philipp Schmid - Adapx
 
P

Philipp Schmid

Yes, I can convert ink that I wrote directly to OneNote to text. As mentioned
below, when I look at the page content (by calling GetPageContent()) I see
the InkWord objects which suggests that ink is indeed recognized.

The machine (running Vista) has both the Windows XP Tablet PC Edition 2005
Recognizer Pack and the Windows XP Tablet PC Edition Development Kit Version
1.7 installed.

-- Philipp Schmid - Adapx


Lin said:
Can you convert ink that you write directly to OneNote? If you have desktop
OS instead of tablet OS, handwriting recognizer is not installed by default.

-Lin (MS)

Philipp Schmid said:
I am programmatically insert ink into a OneNote page using the code below.
The inkdrawing object is properly rendered in the requested page. However,
the ink is not searchable and the context menu has the 'Convert Handwriting
to Text' item grayed out. I am setting isUnclassified to true which should
make the inserted ink searchable, but that doesn't seem to be the case. Is
there another step that I need to perform to get this to work? Note that if I
draw on the same page using the mouse I can create searchable ink just fine
and furthermore the page content contains appropriate InkWord objects.

Main code:

string textContent = CreateText(pageId); // see below
Validate(textContent); // no validation errors

_app.UpdatePageContent(textContent, DateTime.MinValue);


and code that creates the XML:

private string CreateText(string pageId)
{
string resultString;
using (StringWriter stringWriter = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
{
string pageGUID = pageId.Substring(0, pageId.Length - 7);
string pagePath = @"Projects\Economica.one";

writer.WriteStartElement("one:page");
writer.WriteAttributeString("xmlns:eek:ne",
@"http://schemas.microsoft.com/office/onenote/2007/onenote");
writer.WriteAttributeString("ID", pageId);

writer.WriteStartElement("one:InkDrawing");
writer.WriteAttributeString("isUnclassified", "true");
writer.WriteAttributeString("inkOriginX", "0");
writer.WriteAttributeString("inkOriginY", "0");

writer.WriteStartElement("one:ShapeInfo");
writer.WriteStartElement("one:AnchorPoint");
writer.WriteAttributeString("x", "120");
writer.WriteAttributeString("y", "160");
writer.WriteEndElement(); // - one:AnchorPoint
writer.WriteEndElement(); // - one:ShapeInfo

writer.WriteStartElement("one:Data");
writer.WriteCData(GetSampleData());
writer.WriteEndElement(); // - one:Data

writer.WriteEndElement(); // - one:InkDrawing
writer.WriteEndElement(); // - one:page
}
resultString = stringWriter.ToString();
}
return resultString;
}

which creates the following XML string:

- <one:page
xmlns:eek:ne="http://schemas.microsoft.com/office/onenote/2007/onenote"
ID="{6A46FB6A-8A90-4D90-B87F-E998E4C5E95E}{1}{B0}">
- <one:InkDrawing isUnclassified="true" inkOriginX="0" inkOriginY="0">
- <one:ShapeInfo>
<one:AnchorPoint x="120" y="160" />
</one:ShapeInfo>
- <one:Data>
- <![CDATA[
AOUFHQTmAYYBAXAqABofi0JwRYR1gL7QRdkEWM9UiuaXxU+PBvi60uGbIr/scczMIrFBiQ67Eyzu
eqHeuxOL5V6zSJyboSVat1ES+oeVMvLsF0G4wBa/8yv0ekVTgCx6GNVEmWVKNAYxWzMUlUCeksyY
S7VqkBwSxVpVAxBIFESAgPwHRTJGMlcNAAAABQYLZU9mZ2gZFDIIAIAUAnaM4kEzCACAEALa7OJB
Eauq00FkAxVGAEBKGDapo08wFTlp5gOmjTzALdPLTzAdOWnmAABPCQRqAxVGAEBpED6ARSgAABXU
AAHi8AAaygAACmVRgv4CE/gIVYLALAAAAAAsAAASksqC/gIr+Ai5UsqWWUlllhYsssWWWLLLLFll
gWWWKllligo/QCNLQT3MF+A44AkEEgARIB9NL142b/RKtMpCz+i/yv4FFEYAQAAABRRGAEAAAApO
IIL+ATP4BNuWXNxcEKVZVTSC/gIb+AhyUAAAs3LACj9AIhmBSSQX4DjgCQQSABEg+fZC1Mry4Uug
gWCjX05u/QUURgBAAAAFFEYAgAAACp0BwgGC/gKD+AoQAFgWAAAAlGaliykWLKlibLmgAACUBKll
zZLDctlAWBYAAAAAAACC/gJL+Ak5ZcqIzU3Ksqi1LYtgLlECUlSwlli5RNgBNixZZYqUlllAbFlE
WJUqWVLLFRBFhSVNk2RubLNJoAoAESBgl3QpfkHHAQkEEgARIFmPLk5Sfg1ArcB74/ROTZkFFEYA
QAAABRRGAMAAAAppR4L+BJP4Enm5ZSwlipYWAiUiW52Xcs3Nlm5UXBYAgv4C4/gLlYssACVLLLFi
bLlLKllliiLFqWWACgARIMCS/ip+QccBCQQSABEgJH31egB1nEGgY21wrQc+1AUURgBAAAAFFEYB
AAAACjcBCX6ACWuACgARIMCf4St+QccBCQQSABEgS1aTMddqgkeQgsJk3d9xIAUURgBAAAAFFEYBQAAA
]]>
</one:Data>
</one:InkDrawing>
</one:page>


Any help would be much appreciated!

-- Philipp Schmid - Adapx
 
L

Lin

Can you share with us a .one file that is created by your code?

-Lin (MS)

Philipp Schmid said:
Yes, I can convert ink that I wrote directly to OneNote to text. As mentioned
below, when I look at the page content (by calling GetPageContent()) I see
the InkWord objects which suggests that ink is indeed recognized.

The machine (running Vista) has both the Windows XP Tablet PC Edition 2005
Recognizer Pack and the Windows XP Tablet PC Edition Development Kit Version
1.7 installed.

-- Philipp Schmid - Adapx


Lin said:
Can you convert ink that you write directly to OneNote? If you have desktop
OS instead of tablet OS, handwriting recognizer is not installed by default.

-Lin (MS)

Philipp Schmid said:
I am programmatically insert ink into a OneNote page using the code below.
The inkdrawing object is properly rendered in the requested page. However,
the ink is not searchable and the context menu has the 'Convert Handwriting
to Text' item grayed out. I am setting isUnclassified to true which should
make the inserted ink searchable, but that doesn't seem to be the case. Is
there another step that I need to perform to get this to work? Note that if I
draw on the same page using the mouse I can create searchable ink just fine
and furthermore the page content contains appropriate InkWord objects.

Main code:

string textContent = CreateText(pageId); // see below
Validate(textContent); // no validation errors

_app.UpdatePageContent(textContent, DateTime.MinValue);


and code that creates the XML:

private string CreateText(string pageId)
{
string resultString;
using (StringWriter stringWriter = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
{
string pageGUID = pageId.Substring(0, pageId.Length - 7);
string pagePath = @"Projects\Economica.one";

writer.WriteStartElement("one:page");
writer.WriteAttributeString("xmlns:eek:ne",
@"http://schemas.microsoft.com/office/onenote/2007/onenote");
writer.WriteAttributeString("ID", pageId);

writer.WriteStartElement("one:InkDrawing");
writer.WriteAttributeString("isUnclassified", "true");
writer.WriteAttributeString("inkOriginX", "0");
writer.WriteAttributeString("inkOriginY", "0");

writer.WriteStartElement("one:ShapeInfo");
writer.WriteStartElement("one:AnchorPoint");
writer.WriteAttributeString("x", "120");
writer.WriteAttributeString("y", "160");
writer.WriteEndElement(); // - one:AnchorPoint
writer.WriteEndElement(); // - one:ShapeInfo

writer.WriteStartElement("one:Data");
writer.WriteCData(GetSampleData());
writer.WriteEndElement(); // - one:Data

writer.WriteEndElement(); // - one:InkDrawing
writer.WriteEndElement(); // - one:page
}
resultString = stringWriter.ToString();
}
return resultString;
}

which creates the following XML string:

- <one:page
xmlns:eek:ne="http://schemas.microsoft.com/office/onenote/2007/onenote"
ID="{6A46FB6A-8A90-4D90-B87F-E998E4C5E95E}{1}{B0}">
- <one:InkDrawing isUnclassified="true" inkOriginX="0" inkOriginY="0">
- <one:ShapeInfo>
<one:AnchorPoint x="120" y="160" />
</one:ShapeInfo>
- <one:Data>
- <![CDATA[
AOUFHQTmAYYBAXAqABofi0JwRYR1gL7QRdkEWM9UiuaXxU+PBvi60uGbIr/scczMIrFBiQ67Eyzu
eqHeuxOL5V6zSJyboSVat1ES+oeVMvLsF0G4wBa/8yv0ekVTgCx6GNVEmWVKNAYxWzMUlUCeksyY
S7VqkBwSxVpVAxBIFESAgPwHRTJGMlcNAAAABQYLZU9mZ2gZFDIIAIAUAnaM4kEzCACAEALa7OJB
Eauq00FkAxVGAEBKGDapo08wFTlp5gOmjTzALdPLTzAdOWnmAABPCQRqAxVGAEBpED6ARSgAABXU
AAHi8AAaygAACmVRgv4CE/gIVYLALAAAAAAsAAASksqC/gIr+Ai5UsqWWUlllhYsssWWWLLLLFll
gWWWKllligo/QCNLQT3MF+A44AkEEgARIB9NL142b/RKtMpCz+i/yv4FFEYAQAAABRRGAEAAAApO
IIL+ATP4BNuWXNxcEKVZVTSC/gIb+AhyUAAAs3LACj9AIhmBSSQX4DjgCQQSABEg+fZC1Mry4Uug
gWCjX05u/QUURgBAAAAFFEYAgAAACp0BwgGC/gKD+AoQAFgWAAAAlGaliykWLKlibLmgAACUBKll
zZLDctlAWBYAAAAAAACC/gJL+Ak5ZcqIzU3Ksqi1LYtgLlECUlSwlli5RNgBNixZZYqUlllAbFlE
WJUqWVLLFRBFhSVNk2RubLNJoAoAESBgl3QpfkHHAQkEEgARIFmPLk5Sfg1ArcB74/ROTZkFFEYA
QAAABRRGAMAAAAppR4L+BJP4Enm5ZSwlipYWAiUiW52Xcs3Nlm5UXBYAgv4C4/gLlYssACVLLLFi
bLlLKllliiLFqWWACgARIMCS/ip+QccBCQQSABEgJH31egB1nEGgY21wrQc+1AUURgBAAAAFFEYB
AAAACjcBCX6ACWuACgARIMCf4St+QccBCQQSABEgS1aTMddqgkeQgsJk3d9xIAUURgBAAAAFFEYBQAAA
]]>
</one:Data>
</one:InkDrawing>
</one:page>


Any help would be much appreciated!

-- Philipp Schmid - Adapx
 
I

Ilya Koulchin

Try omitting the ShapeInfo and AnchorPoint elements when importing the
XML - that should cause the ink analyzer to run and recognize the words
in the imported ink.
The ShapeInfo is intended for use primarily with the drawing tools. You
may have noticed how lines and other drawing tools "snap" to other
locations on other shapes - the snapping behavior is defined by the
ShapeInfo/AnchorPoints.

Ilya
 
P

Philipp Schmid

Below is the source code for my class that I call from a simple command line
application. You will have to change the XPath query to point to a page in
your file. When I run this against my file I see the word 'This' appear, but
it is not searchable or convertable.

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.OneNote;
using System.Diagnostics;
using System.Xml.XPath;
using System.IO;
using System.Xml.Schema;

namespace OneNoteAddOn1
{
public class AddOn
{
ApplicationClass _app;
public AddOn()
{
_app = new ApplicationClass();
}

public void Run()
{
string hierarchy;
_app.GetHierarchy(null, HierarchyScope.hsPages, out hierarchy);
XmlDocument entireDoc = new XmlDocument();
entireDoc.LoadXml(hierarchy);

XmlNamespaceManager xmlns = new
XmlNamespaceManager(entireDoc.NameTable);
xmlns.AddNamespace("one",
@"http://schemas.microsoft.com/office/onenote/2007/onenote");

// CHANGE THE LINE BELOW
XmlNode myPage =
entireDoc.SelectSingleNode(@"//one:page[@name='TestName']", xmlns);
if (myPage != null)
{
string pageId = myPage.Attributes["ID"].Value;
if (!string.IsNullOrEmpty(pageId))
{
string textContent = CreateText(pageId);
Validate(textContent);
_app.UpdatePageContent(textContent, DateTime.MinValue);

}
}
}

private void Validate(string content)
{
try
{
XmlDocument importDom = new XmlDocument();
importDom.LoadXml(content);

importDom.Schemas.Add(@"http://schemas.microsoft.com/office/onenote/2007/onenote", @"c:\temp\simpleimport.xsd");

ValidationEventHandler eventHandler = new
ValidationEventHandler(ValidationEventHandler);
importDom.Validate(eventHandler);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

static void ValidationEventHandler(object sender,
ValidationEventArgs e)
{
switch (e.Severity)
{
case XmlSeverityType.Error:
Console.WriteLine("Error: {0}", e.Message);
break;
case XmlSeverityType.Warning:
Console.WriteLine("Warning {0}", e.Message);
break;
}
}

private string CreateText(string pageId)
{
string resultString;
using (StringWriter stringWriter = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
{
writer.WriteStartElement("one:page");
writer.WriteAttributeString("xmlns:eek:ne",
@"http://schemas.microsoft.com/office/onenote/2007/onenote");
writer.WriteAttributeString("ID", pageId);

writer.WriteStartElement("one:InkDrawing");
writer.WriteAttributeString("isUnclassified", "true");
writer.WriteAttributeString("inkOriginX", "0");
writer.WriteAttributeString("inkOriginY", "0");

writer.WriteStartElement("one:ShapeInfo");
writer.WriteStartElement("one:AnchorPoint");
writer.WriteAttributeString("x", "120");
writer.WriteAttributeString("y", "160");
writer.WriteEndElement(); // - one:AnchorPoint
writer.WriteEndElement(); // - one:ShapeInfo

writer.WriteStartElement("one:Data");
writer.WriteCData(GetSampleData());
writer.WriteEndElement(); // - one:Data

writer.WriteEndElement(); // - one:InkDrawing
writer.WriteEndElement(); // - one:page

}
resultString = stringWriter.ToString();
}
return resultString;
}

private string GetSampleData()
{
return
"AOUFHQTmAYYBAXAqABofi0JwRYR1gL7QRdkEWM9UiuaXxU+PBvi60uGbIr/scczMIrFBiQ67Eyzu
eqHeuxOL5V6zSJyboSVat1ES+oeVMvLsF0G4wBa/8yv0ekVTgCx6GNVEmWVKNAYxWzMUlUCeksyY
S7VqkBwSxVpVAxBIFESAgPwHRTJGMlcNAAAABQYLZU9mZ2gZFDIIAIAUAnaM4kEzCACAEALa7OJB
Eauq00FkAxVGAEBKGDapo08wFTlp5gOmjTzALdPLTzAdOWnmAABPCQRqAxVGAEBpED6ARSgAABXU
AAHi8AAaygAACmVRgv4CE/gIVYLALAAAAAAsAAASksqC/gIr+Ai5UsqWWUlllhYsssWWWLLLLFll
gWWWKllligo/QCNLQT3MF+A44AkEEgARIB9NL142b/RKtMpCz+i/yv4FFEYAQAAABRRGAEAAAApO
IIL+ATP4BNuWXNxcEKVZVTSC/gIb+AhyUAAAs3LACj9AIhmBSSQX4DjgCQQSABEg+fZC1Mry4Uug
gWCjX05u/QUURgBAAAAFFEYAgAAACp0BwgGC/gKD+AoQAFgWAAAAlGaliykWLKlibLmgAACUBKll
zZLDctlAWBYAAAAAAACC/gJL+Ak5ZcqIzU3Ksqi1LYtgLlECUlSwlli5RNgBNixZZYqUlllAbFlE
WJUqWVLLFRBFhSVNk2RubLNJoAoAESBgl3QpfkHHAQkEEgARIFmPLk5Sfg1ArcB74/ROTZkFFEYA
QAAABRRGAMAAAAppR4L+BJP4Enm5ZSwlipYWAiUiW52Xcs3Nlm5UXBYAgv4C4/gLlYssACVLLLFi
bLlLKllliiLFqWWACgARIMCS/ip+QccBCQQSABEgJH31egB1nEGgY21wrQc+1AUURgBAAAAFFEYB
AAAACjcBCX6ACWuACgARIMCf4St+QccBCQQSABEgS1aTMddqgkeQgsJk3d9xIAUURgBAAAAFFEYBQAAA";
}
}
}




-- Philipp Schmid - Adapx


Lin said:
Can you share with us a .one file that is created by your code?

-Lin (MS)

Philipp Schmid said:
Yes, I can convert ink that I wrote directly to OneNote to text. As mentioned
below, when I look at the page content (by calling GetPageContent()) I see
the InkWord objects which suggests that ink is indeed recognized.

The machine (running Vista) has both the Windows XP Tablet PC Edition 2005
Recognizer Pack and the Windows XP Tablet PC Edition Development Kit Version
1.7 installed.

-- Philipp Schmid - Adapx


Lin said:
Can you convert ink that you write directly to OneNote? If you have desktop
OS instead of tablet OS, handwriting recognizer is not installed by default.

-Lin (MS)

:

I am programmatically insert ink into a OneNote page using the code below.
The inkdrawing object is properly rendered in the requested page. However,
the ink is not searchable and the context menu has the 'Convert Handwriting
to Text' item grayed out. I am setting isUnclassified to true which should
make the inserted ink searchable, but that doesn't seem to be the case. Is
there another step that I need to perform to get this to work? Note that if I
draw on the same page using the mouse I can create searchable ink just fine
and furthermore the page content contains appropriate InkWord objects.

Main code:

string textContent = CreateText(pageId); // see below
Validate(textContent); // no validation errors

_app.UpdatePageContent(textContent, DateTime.MinValue);


and code that creates the XML:

private string CreateText(string pageId)
{
string resultString;
using (StringWriter stringWriter = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
{
string pageGUID = pageId.Substring(0, pageId.Length - 7);
string pagePath = @"Projects\Economica.one";

writer.WriteStartElement("one:page");
writer.WriteAttributeString("xmlns:eek:ne",
@"http://schemas.microsoft.com/office/onenote/2007/onenote");
writer.WriteAttributeString("ID", pageId);

writer.WriteStartElement("one:InkDrawing");
writer.WriteAttributeString("isUnclassified", "true");
writer.WriteAttributeString("inkOriginX", "0");
writer.WriteAttributeString("inkOriginY", "0");

writer.WriteStartElement("one:ShapeInfo");
writer.WriteStartElement("one:AnchorPoint");
writer.WriteAttributeString("x", "120");
writer.WriteAttributeString("y", "160");
writer.WriteEndElement(); // - one:AnchorPoint
writer.WriteEndElement(); // - one:ShapeInfo

writer.WriteStartElement("one:Data");
writer.WriteCData(GetSampleData());
writer.WriteEndElement(); // - one:Data

writer.WriteEndElement(); // - one:InkDrawing
writer.WriteEndElement(); // - one:page
}
resultString = stringWriter.ToString();
}
return resultString;
}

which creates the following XML string:

- <one:page
xmlns:eek:ne="http://schemas.microsoft.com/office/onenote/2007/onenote"
ID="{6A46FB6A-8A90-4D90-B87F-E998E4C5E95E}{1}{B0}">
- <one:InkDrawing isUnclassified="true" inkOriginX="0" inkOriginY="0">
- <one:ShapeInfo>
<one:AnchorPoint x="120" y="160" />
</one:ShapeInfo>
- <one:Data>
- <![CDATA[
AOUFHQTmAYYBAXAqABofi0JwRYR1gL7QRdkEWM9UiuaXxU+PBvi60uGbIr/scczMIrFBiQ67Eyzu
eqHeuxOL5V6zSJyboSVat1ES+oeVMvLsF0G4wBa/8yv0ekVTgCx6GNVEmWVKNAYxWzMUlUCeksyY
S7VqkBwSxVpVAxBIFESAgPwHRTJGMlcNAAAABQYLZU9mZ2gZFDIIAIAUAnaM4kEzCACAEALa7OJB
Eauq00FkAxVGAEBKGDapo08wFTlp5gOmjTzALdPLTzAdOWnmAABPCQRqAxVGAEBpED6ARSgAABXU
AAHi8AAaygAACmVRgv4CE/gIVYLALAAAAAAsAAASksqC/gIr+Ai5UsqWWUlllhYsssWWWLLLLFll
gWWWKllligo/QCNLQT3MF+A44AkEEgARIB9NL142b/RKtMpCz+i/yv4FFEYAQAAABRRGAEAAAApO
IIL+ATP4BNuWXNxcEKVZVTSC/gIb+AhyUAAAs3LACj9AIhmBSSQX4DjgCQQSABEg+fZC1Mry4Uug
gWCjX05u/QUURgBAAAAFFEYAgAAACp0BwgGC/gKD+AoQAFgWAAAAlGaliykWLKlibLmgAACUBKll
zZLDctlAWBYAAAAAAACC/gJL+Ak5ZcqIzU3Ksqi1LYtgLlECUlSwlli5RNgBNixZZYqUlllAbFlE
WJUqWVLLFRBFhSVNk2RubLNJoAoAESBgl3QpfkHHAQkEEgARIFmPLk5Sfg1ArcB74/ROTZkFFEYA
QAAABRRGAMAAAAppR4L+BJP4Enm5ZSwlipYWAiUiW52Xcs3Nlm5UXBYAgv4C4/gLlYssACVLLLFi
bLlLKllliiLFqWWACgARIMCS/ip+QccBCQQSABEgJH31egB1nEGgY21wrQc+1AUURgBAAAAFFEYB
AAAACjcBCX6ACWuACgARIMCf4St+QccBCQQSABEgS1aTMddqgkeQgsJk3d9xIAUURgBAAAAFFEYBQAAA
]]>
</one:Data>
</one:InkDrawing>
</one:page>


Any help would be much appreciated!

-- Philipp Schmid - Adapx
 
P

Philipp Schmid

Progress: the page content now contains an one:InkWord but no recognizedText:

<one:InkParagraph x="0.0" y="0.00944137573242187" width="84.78424835205078"
height="47.99055099487304">
- <one:InkWord x="0.0" y="0.0" width="84.7842559814453"
height="48.78424072265625">

<one:Data>AIQFHQTmAYYBAUBYz1SK5pfFT48G+LrS4Zsiv+xxzMwisUGJDrsTLO56od67E4vlXrNInJuhJVq3
URL6h5Uy8uwXQbjAFr/zK/R6AxBIFESAgPwHRTJGMlcNAAAABQYLZE9lZmcZFDIIAIAUAnaM4kEz
CACAEALa7OJBFauq00GrqtNBAACUxQBQqsUKTiCC/gEz+ATbllzcXBClWVU0gv4CG/gIclAAALNy
wAo/QCIZgUkkF+A44AkEEgARIPn2QtTK8uFLoIFgo19Obv0FFEYAQAAABRRGAIAAAAplUYL+AhP4
CFWCwCwAAAAALAAAEpLKgv4CK/gIuVLKlllJZZYWLLLFlliyyyxZZYFllipZZYoKP0AjS0E9zBfg
OOAJBBIAESAfTS9eNm/0SrTKQs/ov8r+BRRGAEAAAAUURgBAAAAKnQHCAYL+AoP4ChAAWBYAAACU
ZqWLKRYsqWJsuaAAAJQEqWXNksNy2UBYFgAAAAAAAIL+Akv4CTllyojNTcqyqLUti2AuUQJSVLCW
WLlE2AE2LFllipSWWUBsWURYlSpZUssVEEWFJU2TZG5ss0mgCgARIGCXdCl+QccBCQQSABEgWY8u
TlJ+DUCtwHvj9E5NmQUURgBAAAAFFEYAwAAACjcBCX6ACWuACgARIMCf4St+QccBCQQSABEgS1aT
MddqgkeQgsJk3d9xIAUURgBAAAAFFEYBQAAACmlHgv4Ek/gSebllLCWKlhYCJSJbnZdyzc2WblRc
FgCC/gLj+AuViywAJUsssWJsuUsqWWWKIsWpZYAKABEgwJL+Kn5BxwEJBBIAESAkffV6AHWcQaBj
bXCtBz7UBRRGAEAAAAUURgEAAAA=</one:Data>
</one:InkWord>
</one:InkParagraph>

-- Philipp Schmid - Adapx
 
I

Ilya Koulchin

Philipp said:
Progress: the page content now contains an one:InkWord but no recognizedText:

Ink recognition is a somewhat complicated matter. The short version is
it will run when OneNote is running, viewing the page, and the computer
is idle, so it may take a bit for the results to show up. The same
process that triggers ink classification (into InkWords or InkDrawings)
will also trigger recognition, but not right away, since it is a more
CPU-intensive task. Since in your case the ink already has been
classified into InkWords, I'd just give the ink engine some more time to
do the work to run recognition.
It is also possible that ink recognition has already been triggered but
failed to produce results. This may be possible if the ink sample is of
a poor quality - the TabletPC digitizer samples the pen hundreds of
times each second, so ink drawn with the mouse is at a disadvantage when
it comes to recognition.

Ilya
 
P

Philipp Schmid

I am using the same one:Data block that I copied from another InkWord that
was recognized on the same page. Therefore I expect to get the same
recognition result.

I posted my repro steps earlier in this thread. You simply have to change
the line that searches for my page to point to a page in your notebook and
you should be able to duplicate my program.

As a side-note, I just tried to insert the same ink (in one:Data) but this
time using a one:InkWord and setting the recognizedText to some unique string
(say 'Christmas'). The ink got rendered (there are some positioning/offset
problems). However, the recognizedText attribute was ignored and when I
subsequently retrieved the page content (calling GetPageContent()) the
attribute was missing! So the idea to do segmentation and recognition prior
to importing doesn't seem to work either! Should it work?

-- Philipp Schmid - Adapx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top