Exploring the AFD File

by alocurto Email

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

Comment from: Gab [Visitor]
Hi...
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?
12/09/08 @ 13:25
Comment from: gopi [Visitor] Email
Since this is C#, do you think that the AFD parser is able to run without win32-specific APIs? ie, can I run it with Mono on my Mac?

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.
12/11/08 @ 12:32
Comment from: Nick [Visitor]
To Gab:

You need to copy the tools.jar file to the proper directory
12/21/08 @ 19:32

This post has 3 feedbacks awaiting moderation...

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)