OneNote.PageContent class

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.

[ API set: OneNoteApi 1.1 ]

Extends
OfficeExtension.ClientObject

Properties

id

Gets the ID of the PageContent object. Read-only.

[ API set: OneNoteApi 1.1 ]

image

Gets the Image in the PageContent object. Throws an exception if PageContentType is not Image.

[ API set: OneNoteApi 1.1 ]

ink

Gets the ink in the PageContent object. Throws an exception if PageContentType is not Ink.

[ API set: OneNoteApi 1.1 ]

left

Gets or sets the left (X-axis) position of the PageContent object.

[ API set: OneNoteApi 1.1 ]

outline

Gets the Outline in the PageContent object. Throws an exception if PageContentType is not Outline.

[ API set: OneNoteApi 1.1 ]

parentPage

Gets the page that contains the PageContent object. Read-only.

[ API set: OneNoteApi 1.1 ]

top

Gets or sets the top (Y-axis) position of the PageContent object.

[ API set: OneNoteApi 1.1 ]

type

Gets the type of the PageContent object. Read-only.

[ API set: OneNoteApi 1.1 ]

Methods

delete()

Deletes the PageContent object.

[ API set: OneNoteApi 1.1 ]

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

toJSON()
track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created.

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect.

Property Details

id

Gets the ID of the PageContent object. Read-only.

[ API set: OneNoteApi 1.1 ]

readonly id: string;

Property Value

string

image

Gets the Image in the PageContent object. Throws an exception if PageContentType is not Image.

[ API set: OneNoteApi 1.1 ]

readonly image: OneNote.Image;

Property Value

ink

Gets the ink in the PageContent object. Throws an exception if PageContentType is not Ink.

[ API set: OneNoteApi 1.1 ]

readonly ink: OneNote.FloatingInk;

Property Value

left

Gets or sets the left (X-axis) position of the PageContent object.

[ API set: OneNoteApi 1.1 ]

left: number;

Property Value

number

outline

Gets the Outline in the PageContent object. Throws an exception if PageContentType is not Outline.

[ API set: OneNoteApi 1.1 ]

readonly outline: OneNote.Outline;

Property Value

parentPage

Gets the page that contains the PageContent object. Read-only.

[ API set: OneNoteApi 1.1 ]

readonly parentPage: OneNote.Page;

Property Value

top

Gets or sets the top (Y-axis) position of the PageContent object.

[ API set: OneNoteApi 1.1 ]

top: number;

Property Value

number

type

Gets the type of the PageContent object. Read-only.

[ API set: OneNoteApi 1.1 ]

readonly type: OneNote.PageContentType | "Outline" | "Image" | "Ink" | "Other";

Property Value

OneNote.PageContentType | "Outline" | "Image" | "Ink" | "Other"

Method Details

delete()

Deletes the PageContent object.

[ API set: OneNoteApi 1.1 ]

delete(): void;

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(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(option?: string | string[]): OneNote.PageContent;

Parameters

option
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

Remarks

In addition to this signature, this method has the following signatures:

load(option?: { select?: string; expand?: string; }): OneNote.PageContent - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): OneNote.PageContent - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

toJSON()

toJSON(): OneNote.Interfaces.PageContentData;

Returns

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created.

track(): OneNote.PageContent;

Returns

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect.

untrack(): OneNote.PageContent;

Returns