Exploring the AFD File
Having extracted the AFD file from the pen in a previous post I started poking around the contents of it. I then started looking through the LiveScribe desktop DLLs for methods that would help me in getting data out. My goal in this whole exploration of the AFD is to get stroke data off the pen and I managed to find that in the AFD file. I created a C# project and added the following references to "C:\Program Files\Livescribe\Livescribe Desktop\LS.Desktop.AFDDB.dll". Once you add that reference to the project, you can get the stroke contents of the AFD file like so:
LS.Desktop.AFDDB.LSDocument doc = LS.Desktop.AFDDB.LSDocument.LoadDocument("YOURPATHHERE.AFD");
//Check for strokes
if (doc.HasStrokes(0))
{
Console.WriteLine("Has Strokes!");
//Go through each page
for (int pageno = 0; pageno < doc.pageInstances.Count; pageno++)
{
Console.WriteLine(string.Format("Page No {0}", pageno));
//Go through each stroke
for (int strokeno = 0; strokeno < doc.pageInstances[pageno].NumStrokes; strokeno++)
{
Console.WriteLine(string.Format("\tStroke No {0}", strokeno));
//Go through the points
foreach (Point p in doc.pageInstances[pageno].GetStroke(strokeno).Points)
{
Console.WriteLine(string.Format("\t\t({0}, {1})", p.X, p.Y));
}
}
}
}
else
{
Console.WriteLine("No Strokes!");
}
You can use that object to get other things too. If you have any questions or need help just send me an e-mail or post a comment. I would be glad to assist.
-Anthony
3 comments
I recently started playing around with Eclipse and Livescribe development, but every time I try to deploy the penlet I get the following error:
C:\Eclipse\plugins\com.livescribe.sdk.lib_0.8.8\ant\build-common.xml:139: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre6"
Can you help me, please?
Poking around, I think that the Mac side has native shared libraries with similar APIs. I will try to poke more deeply in the next couple days, but I do like the idea of a potential platform-agnostic AFD parser.
You need to copy the tools.jar file to the proper directory
This post has 3 feedbacks awaiting moderation...
12/03/08 09:34:05 am, 