PageContent Object (JavaScript API for OneNote)

Applies to: OneNote Online

Represents a region on a page that contains top-level content types such as Outline or Image. A PageContent object can be assigned an XY position.

Properties

Property Type Description Feedback
id string Gets the ID of the PageContent object. Read-only. Go
left double Gets or sets the left (X-axis) position of the PageContent object. Go
top double Gets or sets the top (Y-axis) position of the PageContent object. Go
type string Gets the type of the PageContent object. Read-only. Possible values are: Outline, Image, Other. Go

Relationships

Relationship Type Description Feedback
image Image Gets the Image in the PageContent object. Throws an exception if PageContentType is not Image. Read-only. Go
ink FloatingInk Gets the ink in the PageContent object. Throws an exception if PageContentType is not Ink. Read-only. Go
outline Outline Gets the Outline in the PageContent object. Throws an exception if PageContentType is not Outline. Read-only. Go
parentPage Page Gets the page that contains the PageContent object. Read-only. Go

Methods

Method Return Type Description Feedback
delete() void Deletes the PageContent object. Go
load(param: object) void Fills the proxy object created in JavaScript layer with property and object values specified in the parameter. Go

Method Details

delete()

Deletes the PageContent object.

Syntax

pageContentObject.delete();

Parameters

None

Returns

void

Examples

OneNote.run(function (context) {

    var page = context.application.getActivePage();
    var pageContents = page.contents;

    var firstPageContent = pageContents.getItemAt(0);
    firstPageContent.load('type');

    // Run the queued commands, and return a promise to indicate task completion.
    return context.sync()
        .then(function () {
            if(firstPageContent.isNull === false) {
                firstPageContent.delete();
                return context.sync();
            }
        });
})
.catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

load(param: object)

Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

Syntax

object.load(param);

Parameters

Parameter Type Description
param object Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object.

Returns

void