Namespace: ContentEdit

Core. ContentEdit

The namespace for APIs dealing with document content editing

Extends

Classes

ContentBox
ContentBoxEditor

Members


<static> Events

Properties:
Name Type Description
TEXT_CONTENT_UPDATED string Core.ContentEdit.textContentUpdated
SEARCH_AND_REPLACE_STARTED string Core.ContentEdit.searchAndReplaceStarted
SEARCH_AND_REPLACE_TEXT_REPLACED string Core.ContentEdit.searchAndReplaceTextReplaced
SEARCH_AND_REPLACE_TEXT_FOUND string Core.ContentEdit.searchAndReplaceTextFound
SEARCH_AND_REPLACE_ENDED string Core.ContentEdit.searchAndReplaceEnded

Methods


<static> addNewParagraph(options, content)

Add a new content box
Parameters:
Name Type Description
options object
Properties
Name Type Description
pageNumber number The page number that the content is on
position string The new position of content box, in PDF coordinates
content string The content to add to the content box
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> alignContents(contentEditPlaceholderAnnotation, alignment)

Align text content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.Annotation The annotation that represents the content where the text alignment should be set
alignment string The text alignment to set. Must be one of the following values: 'START', 'CENTER', or 'END'.
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> getContentEditingFonts()

Get a list of fonts available for content editing
Returns:
Resolves after the content has been updated, returns list of fonts
Type
Promise.<Array.<string>>

<static> getDocumentContent(contentEditPlaceholderAnnotation)

Gets the content box data for the passed in annotation. The passed in annotation must be a content edit placeholder annotation.
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.RectangleAnnotation
Returns:
content The document content associated with this content edit placeholder annotation
Type
Promise.<string>
Example
const content = await instance.Core.ContentEdit.getDocumentContent(contentEditPlaceholderAnnotation);

<static> getResourcePath()

Get the location of the ContentEdit worker resource file InfixServerWasm.br.mem
Returns:
the URL for InfixServerWasm.br.mem file
Type
string

<static> getWorkerPath()

Get the location of the ContentEdit worker files InfixServerModule.js, InfixServerWasm.br.js.mem, InfixServerWasm.br.wasm, and InfixServerWasm.gz.js.mem
Returns:
the URL for InfixServerModule.js, InfixServerWasm.br.js.mem, InfixServerWasm.br.wasm, and InfixServerWasm.gz.js.mem files
Type
string

<static> loadTextAttributes(id, startIndex [, restrictOptions], selectionLength)

Load selected text attributes from infixserver
Parameters:
Name Type Argument Description
id String The id of the content box, the OID currently
startIndex Number The index where the change start
restrictOptions object <optional>
An object that set returns for font name or font size
Properties
Name Type Argument Description
fontName Boolean <optional>
Font name is not returned when restrictFontName is true
fontSize Boolean <optional>
Font size is not returned when restrictFontSize is true
selectionLength Number The length from start index to end index or selected text
Returns:
Type
Promise.<void>

<static> preloadWorker(contentEditManager)

Preloads the content editing worker. If this function isn't called then the worker will be loaded when the content editing tool is enabled.
Parameters:
Name Type Description
contentEditManager Core.ContentEditManager The contentEditManager to use as context for the page editing.
Returns:
Resolves after the worker has been loaded
Type
Promise.<void>

<static> regeneratePage()

Sends a command to the worker to regenerate the content boxes and page content.
Returns:
Resolves after the page is prepared for editing
Type
Promise.<void>

<static> searchAndReplaceText(options)

A function that will search and replace text inside the document.
Parameters:
Name Type Description
options object
Properties
Name Type Argument Description
toReplace string | RegExp A string or global RegExp object that will be replaced on the page.
replaceWith string The string that replaces the string or RegExp provided in the first parameter.
documentViewer Core.DocumentViewer DocumentViewer instance.
searchResults Array.<Core.Search.SearchResult> the array of search results.
caseSensitive boolean <optional>
Is case sensitive search.
wholeWord boolean <optional>
Is serching the whole word.
wildcard boolean <optional>
Is searching with wildcard word.
regex boolean <optional>
Is searching with regular expression.
isSingleSearchReplace boolean <optional>
Is it single search and replace or whole document.
Returns:
Returns promise which will resolve when the operation completes.
Type
Promise.<void>
Example
instance.Core.ContentEdit.searchAndReplaceText({
   toReplace: 'PDF',
   replaceWith: 'DOCX',
   documentViewer: instance.Core.documentViewer,
   searchResults: instance.Core.documentViewer.getPageSearchResults([1])
});

<static> setContentFont(contentEditPlaceholderAnnotation, font)

Set font of text content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.Annotation The annotation that represents the content where the font should be set
font string The font family to set
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> setContentFontSize(contentEditPlaceholderAnnotation, size)

Set font size of text content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.Annotation The annotation that represents the content where font size should be set
size string The font size to set
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> setResourcePath(workerPath)

Set the location of the ContentEdit worker resource file InfixServerWasm.br.mem This will override the location specified by Core.setWorkerPath for InfixServerWasm.br.mem file.
Parameters:
Name Type Description
workerPath string the URL for InfixServerWasm.br.mem file

<static> setTextAttributes(attributes)

Sets the active text attributes to be applied to new text
Parameters:
Name Type Description
attributes Object The attributes to set
Properties
Name Type Argument Description
fontName String <optional>
The font name
fontSize String <optional>
The font size
bold Boolean <optional>
Whether the text is bold
italic Boolean <optional>
Whether the text is italic
underline Boolean <optional>
Whether the text is underlined
fontColor String <optional>
The hex color of the text
Returns:
Type
Promise.<void>

<static> setTextColor(contentEditPlaceholderAnnotation, color)

Set font color of text content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.Annotation The annotation that represents the content where the text color should be set
color String The color of the text to set
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> setWorkerPath(workerPath)

Set the location of the ContentEdit workers for InfixServerModule.js, InfixServerWasm.br.js.mem, InfixServerWasm.br.wasm, and InfixServerWasm.gz.js.mem files. This will override the location specified by Core.setWorkerPath for ContentEdit worker files.
Parameters:
Name Type Description
workerPath string the URL for InfixServerModule.js, InfixServerWasm.br.js.mem, InfixServerWasm.br.wasm, and InfixServerWasm.gz.js.mem files

<static> toggleBoldContents(contentEditPlaceholderAnnotation)

Bold or unbold text content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.Annotation The annotation that represents the content where bold should be toggled
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> toggleItalicContents(contentEditPlaceholderAnnotation)

Italicize or unitalicize text content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.Annotation The annotation that represents the content where italics should be toggled
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> toggleStrikeContents(contentEditPlaceholderAnnotation)

Strike or de-strike text content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.Annotation The annotation that represents the content where underline should be toggled
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> toggleUnderlineContents(contentEditPlaceholderAnnotation)

Underline or de-underline text content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.Annotation The annotation that represents the content where underline should be toggled
Returns:
Resolves after the content has been updated
Type
Promise.<void>

<static> updateDocumentContent(contentEditPlaceholderAnnotation, content)

Update the document with new content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.RectangleAnnotation
content string The new content
Returns:
Resolves after the content has been updated
Type
Promise.<void>
Example
instance.Core.ContentEdit.updateDocumentContent(contentEditPlaceholderAnnotation, 'New content');

addEventListener(type, fn [, options])

Add a handler to the given event name
Parameters:
Name Type Argument Description
type string | number The name of the event to listen to
fn function The handler to be called when the event is triggered
options object <optional>
Optional options object for addEventListener
Properties
Name Type Description
once boolean If true then the handler will be called only once
Returns:
Returns the object that 'addEventListener' is being called on
Type
object
Example
Core.ContentEdit.addEventListener('textContentUpdated', (originalText, updatedText, boundingBoxCoordinates) => {
  ...
});

removeEventListener( [type] [, fn])

Remove a handler of the given event name and namespace (if given) or with a function reference
Parameters:
Name Type Argument Description
type string | number <optional>
The name of the event to remove the handler of with an optional namespace.
fn function <optional>
The handler associated with this event to be removed. If fn is undefined, all the handlers of the given event namespace will be removed If you are not passing in this parameter then a namespace must be used with the event name.
Returns:
Returns the object that 'removeEventListener' is being called on
Type
object
Example
Core.ContentEdit.removeEventListener('textContentUpdated.namespace');
Core.ContentEdit.removeEventListener('textContentUpdated', fn);

trigger(type [, data])

Calls the handlers of the event name with given data
Parameters:
Name Type Argument Description
type string | number event name of which the handlers will be called.
data * <optional>
data that will be passed to the handlers. If data is an array, it will be spread and then passed to the handlers
Returns:
Returns the object that 'trigger' is being called on
Type
object
Example
Core.ContentEdit.trigger('textContentUpdated', originalText, updatedText, boundingBoxCoordinates);

Type Definitions


Types

Content Edit types.
Properties:
Name Type Description
TEXT string Text type content.
OBJECT string Object type content, currently image only.

Events


editBoxesAvailable

Triggered any time edit boxes are drawn on the page.
Parameters:
Name Type Description
boxes object An array of Content Edit boxes.

textContentUpdated

Triggered when text content of the page is updated.
Parameters:
Name Type Description
originalText string The original text of the selected bounding box.
updatedText string The updated text of the selected bounding box.
boundingBoxCoordinates Core.Math.Rect The coordinates (top, left, bottom, right) of the bounding box.

undoRedoStatusChanged

Triggers when the undo redo status is changed. Can be used together with contentEditHisotryManager.undo or contentEditHisotryManager.redo
Example
Core.ContentEdit.addEventListener('undoRedoStatusChanged', () => {
  console.log('can undo?', contentEditHistoryManager.canUndo())
  console.log('can redo?', contentEditHistoryManager.canRedo())
});