Interface: Session

Session

This describes the content editor session returned by PSPDFKit.Instance#beginContentEditingSession.

It is independent of the content editor UI session, which is used to display the content editor UI. At one time, only one content editing session can be active, either this session or a UI session. Starting the UI session will deactivate this session. Also, if the contents of an opened document are modified while this session is active, the session will be deactivated.

Using this requires a license that includes the Content Editor component.

Members

Methods




Members

active: boolean

Indicates whether the session is currently active.

Type:
  • boolean

Methods

commit()

Completes the current editing session and saves all changes. Document will reload.

Returns:

A promise that resolves when the changes have been successfully saved.

discard()

Completes the current editing session without persisting any changes.

Returns:

A promise that resolves when the session is successfully discarded.

getTextBlocks(pageIndex) → {Promise.<Array.<PSPDFKit.ContentEditing.TextBlock>>}

Retrieves all text blocks for a specific page.

Parameters:
Name Type Description
pageIndex number

The index of the page to retrieve text blocks for.

Throws:

If the page index is out of bounds.

Type
PSPDFKit.Error
Returns:

A promise that resolves with an array of TextBlocks for the given page.

Type
Promise.<Array.<PSPDFKit.ContentEditing.TextBlock>>

updateTextBlocks(textBlocks) → {Promise.<void>}

Updates an array of text blocks with partial data.

If a text block for the corresponding page wasn't previously loaded via getTextBlocks, it will be loaded in the background automatically.

Parameters:
Name Type Description
textBlocks Array.<PSPDFKit.ContentEditing.UpdatedTextBlock>

Array of UpdatedTextBlock objects to update. Each object must be identified through its ID. Other fields are optional and will be updated in the document if not null.

Throws:

If the ID of any text block is missing or doesn't exist.

Type
PSPDFKit.Error
Returns:

A promise that resolves when the update is complete.

Type
Promise.<void>