A powertoy to make using Adapx pens for OneNote a little easier for me

I managed to get my hands on a Capturx pen a while back from AdapX. If you haven't seen these pens, they are pretty nice - you can use their pen and their notebooks to take notes and sync the data to OneNote. It works well, but one aspect of the page their software created always bothered me. If you watch their video on their website closely, you'll see that the pen is "smart" enough to know the physical size of the paper in the notebook you are using. See in the video how the white paper surface doesn't quite go to the edges (and past) in OneNote's UI? When you sync your notes, the page OneNote creates is the same physical size as the paper. In my case, I was using a physical notebook that was about 5 inches by 8 inches, so the resulting pages look something like this:

clip_image001

See all that gray to the right and below? This is to help show you the physical size of the page. The addin Adapx provides gives me an accurate mirror image of my notes from the physical world by sizing the page exactly the same as the physical notebook.

I did not like this behavior, though. Once I sync the notes to OneNote, I want to add more notes to the far right or below what I had already written. In short, I wanted the page to be "infinite" size - this is the OneNote default for new pages. I suppose I had just grown too attached to that automatic sizing.

I had a few choices to get the page size I wanted. I could click File | Page Setup and change the "Custom" size the page had to "Auto:"

clip_image002

clip_image003

This worked, but was tedious after changing a few page sizes. This took me four clicks to complete (the File menu, the Page Setup item, changing the dropdown to Auto and then closing the Page Setup Pane).

I really wanted to change this with one click somewhere in the UI. So I wrote a simple powertoy to do this for me.

In the UI, I added a toolbar icon that is supposed to be a small page at the bottom left getting changed into a bigger page with an infinity symbol on it.

clip_image004

Graphic design skills are not my forte, obviously.

The change to the page XML was pretty simple. Here's the XML from the 5x8 page:

<one:PageSize>
<one:Orientation landscape="false" />
<one:Dimensions width="360.0" height="576.0" />
<one:Margins top="36.0" bottom="36.0" left="72.0" right="72.0" />
</one:PageSize>

Like I said, it's pretty simple. What I want is simpler still:

<one:PageSize>
<one:Automatic />
</one:PageSize>

So all the addin does is get the page content (including the binary information since there is ink on the page) and replaces the existing page size with the "auto" setting. Undo is even supported.

Instead of posting the source code for this powertoy as a VC# project, I'm just pasting the few lines needed for this change here:

In the OnClick Event:

String origPageXML;
onApp.GetPageContent(strActivePageID, out origPageXML, OneNote.PageInfo.piBinaryData );
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(origPageXML);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("one", strNamespace);
XmlNode pageSizeNode = xmlDoc.SelectSingleNode("//one:PageSize", nsmgr);
xmlDoc.SelectSingleNode("//one:PageSize",nsmgr).InnerXml = "<one:Automatic xmlns:one=\"https://schemas.microsoft.com/office/onenote/2007/onenote\" />";
onApp.UpdatePageContent(xmlDoc.InnerXml, System.DateTime.MinValue);

I had one last option. I could have done this with OMSpy - but I hit some problems with that that I want to explain later.

For now, the download link for this page expander powertoy should be under my signature. Have fun!

Questions, comments, concerns and criticisms always welcome,
John

Page_Expander.zip