Diode Dan
Diode Dan

Reputation: 5151

OneNote InkStroke/FloatingInk API

There is an API for getting ink stroke objects in OneNote. Per the examples/documentation you can run code that gets the InkStroke object. My understanding is that Highlighter strokes are FloatingInk in the OneNote object model. Is it possible to get information about the stroke itself? Something like:

if(inkObject.getType() == "Highlighter") {
    var width = inkObject.getStroke().width;
    var height = inkObject.getStroke().height;
}

The documentation shows an example below, but it only appears to make the "id" property available.

OneNote.run(function(context) {

    // Gets the active page.
    var page = context.application.getActivePage();
    var contents = page.contents;

    // Load page contents and their types.
    page.load('contents/type');
    return context.sync()
        .then(function(){

            // Load every ink content.
            $.each(contents.items, function(i, content) {
                if (content.type == "Ink"){
                    content.load('ink/id');
                }                           
            })
            return context.sync();
        })
        .then(function(){

            // Log ID of every ink content.
            $.each(contents.items, function(i, content) {
                if (content.type == "Ink"){
                    console.log(content.ink.id);
                }                           
            })              
        });
})
.catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
}); 

Upvotes: 0

Views: 173

Answers (1)

Jorge Aguirre
Jorge Aguirre

Reputation: 2857

EDIT: While not ideal, you could obtain the RestApiId and then make an API call to retrieve the InkML document, which will contain this information.

https://blogs.msdn.microsoft.com/onenotedev/2017/07/07/onenote-ink-beta-apis/


Unfortunately, there is no way of getting ink stroke coordinate information from OneNote Add-ins. I encourage you to file a uservoice item and link it here.

https://onenote.uservoice.com/forums/245490-onenote-developer-apis/

Upvotes: 1

Related Questions