RtcWhiteboard

Updated at:

This topic describes the details of the RtcWhiteboard interface for the DingRTC Web Whiteboard software development kit (SDK).

Properties

Property

Type

Description

Minimum supported version

isConnected

boolean

Indicates whether the SDK instance is connected to the server.

1.0.1

users

{ userId: string }[]

The users in the current whiteboard or annotation session.

1.0.2

tabletScale

number

The scaling ratio of the handwriting tablet. By default, the tablet is scaled 1:1 to the screen.

1.0.1

tabletMatchMode

'fitWidth' | 'fitHeight'

The matching mode between the handwriting tablet and the canvas. By default, the width is matched.

1.0.1

tabletTranslate

[number, number]

The offset of the handwriting tablet relative to the canvas. This is not affected by scaling.

1.0.1

tabletWriteMode

'static' | 'sticky'

Specifies whether the writing position on the tablet is affected when the canvas is moved. `static`: Moves with the canvas. `sticky`: Does not move with the canvas. The default value is `static`.

1.0.1

sizeConfig

{ width: number; height: number; limited: boolean }

The default size of the canvas.

1.0.1

bgScaleMode

'auto' | 'fillWidth' | 'fillHeight'

The mode for scaling the canvas to fit the background image. The default value is `auto`.

1.0.1

backgroundColor

string

Gets the background color of the current whiteboard view.

1.0.1

fontSize

number

The font size. This applies to newly inserted text. The default value is 18 px.

1.0.1

bold

boolean

Indicates whether the text is bold. This applies to newly inserted text. The default value is `false`.

1.0.1

dashed

boolean

Indicates whether to draw a dashed line. The default value is `false`.

1.0.1

italic

boolean

Indicates whether the text is italic. This applies to newly inserted text. The default value is `false`.

1.0.1

lineWidth

number

The brush width. This applies to newly drawn shapes. The default value is 3 px.

1.0.1

fillType

'none' | 'color'

The fill type for newly drawn shapes. You can fill with a color or not fill. The default value is `color`.

1.0.1

fillStyle

string

The fill color. This applies to newly drawn shapes. The default value is `rgba(112,124,138,1)`.

1.0.1

strokeStyle

string

The brush color. This applies to newly drawn shapes. The default value is `rgba(33,212,183,1)`.

1.0.1

role

'Admin' | 'Attendee' | 'Viewer'

Gets the role of the current user.

1.0.1

isAdmin

boolean

Indicates whether the current user is an admin.

1.0.1

scale

number

The scaling ratio of the current whiteboard view.

1.0.1

pages

number

Gets the currently active document.

1.0.1

activeDocId

string

Gets the ID of the currently active document.

1.0.1

activeDoc

Doc

Gets information about the currently active document.

1.0.1

API List

Interface

Description

Minimum supported version

open()

Opens the whiteboard and joins the whiteboard session.

1.0.1

leave()

Leaves the whiteboard session.

1.0.1

stop()

Stops the whiteboard and its session. Other users receive a signal that the whiteboard is stopped.

1.0.1

close()

Closes the whiteboard but does not stop the whiteboard session. Other users do not receive a signal that the whiteboard is closed.

1.0.1

reset()

Clears the whiteboard state and restores it to the initial state.

1.0.1

undo()

Undoes the last operation on the whiteboard.

1.0.1

redo()

Redoes the last undone operation on the whiteboard.

1.0.1

setToolType()

Sets the tool type.

1.0.1

joinSession()

Rejoins the whiteboard session.

1.0.2

addBackgroundImages()

Imports a specified number of background images and creates a new document that uses these images as the background.

1.0.1

addImageShape()

Adds an image to the whiteboard.

1.0.1

addStamp()

Adds a stamp resource.

1.0.1

addPdfDoc()

Adds a PDF document from a URL and returns the document ID.

1.0.1

addPage()

Adds a new page to the end.

1.0.1

alignVision()

Performs a one-time synchronization of the view during the session.

1.0.1

center()

Resets the whiteboard view to the center (initial position).

1.0.1

clearDocContents()

Clears the content of a document. Admin permissions are required.

1.0.1

clearContents()

Clears the content drawn by all users on the canvas. Admin permissions are required.

1.0.1

clearUserContents()

Clears the content drawn by a specific user. Admin permissions are required to clear content drawn by other users.

1.0.1

createDoc()

Creates a document.

1.0.1

deleteDoc()

Deletes a document.

1.0.1

disableCursorSync()

Disables cursor position synchronization.

1.0.1

disableWheelScale()

Disables canvas scaling using the mouse wheel.

1.0.1

disableScaleAndMove()

Disables scaling the panel and moving the canvas with gestures.

1.0.1

enableCursorSync()

Enables cursor position synchronization.

1.0.1

enableScaleAndMove()

Enables scaling the panel and moving the canvas with gestures.

1.0.1

enableWheelScale()

Enables canvas scaling using the mouse wheel.

1.0.1

enumerateDocs()

Lists information about all documents.

1.0.1

getCurrentPageNumber()

Gets the current page number.

1.0.1

getTotalNumberOfPages()

Gets the total number of pages in the currently active whiteboard document.

1.0.1

getCursorSyncType()

Gets the cursor synchronization type. The cursor can be synchronized for all movements or only when drawing.

1.0.1

getTranslate()

Gets the current horizontal and vertical offset of the canvas.

1.0.1

getToolType()

Gets the current tool type.

1.0.1

getStatistics()

Gets statistics on the shapes created by users.

1.0.1

insertPage()

Insert a document.

1.0.1

prevPage()

Switches to the previous page.

1.0.1

nextPage()

Switches to the next page.

1.0.1

removePage()

Deletes a specified page.

1.0.1

initVision()

Sets the position of the whiteboard viewport. The canvas automatically scales to an appropriate ratio.

1.0.1

setBackgroundImage()

Sets the background image.

1.0.1

setRoleType()

Sets the whiteboard role type.

1.0.1

setBackgroundImageScalingMode()

Sets the scaling mode for the whiteboard background image.

1.0.1

setStamp()

Selects a stamp to use. Before selecting a stamp, you must add the corresponding stamp.

1.0.1

setShapesVisible()

Hides the drawn paths on the whiteboard. All paths are hidden. You can control whether to hide the background image.

1.0.1

setTranslate()

Sets the canvas offset.

1.0.1

setSelectedShapeStyle()

Sets the style of the currently selected shape.

1.0.1

setSelectedShapeFontStyle()

Sets the font style of the currently selected shape.

1.0.1

setCursorSyncType()

Sets the cursor synchronization type.

1.0.1

startFollowVision()

Starts following a view.

1.0.1

stopFollowVision()

Stops following a view.

1.0.1

startVisionShare()

Starts sharing your view. Your view is synchronized with other users.

1.0.1

stopVisionShare()

Stops sharing your view and sends a message to clear your view resource information.

1.0.1

switchToDoc()

Switches the whiteboard document.

1.0.1

snapshot()

Takes a snapshot of the current whiteboard content.

1.0.1

transcodeFile()

Transcodes a file.

1.0.1

uploadImage()

Uploads an image.

1.0.1

uploadPDF()

Uploads a PDF file.

1.0.1

usePdf()

Uses the PDF plugin.

1.0.1

on()

Listens for a specified event and sets a callback function.

1.0.1

once()

Listens for a specified event once. The listener is removed after the callback function is triggered.

1.0.1

off()

Removes the listener for a specified event.

1.0.1

removeAllListeners()

Removes the listeners for a specified event or all events on this object.

1.0.1

Events

DingRTC global events

Event

Callback type

Description

Minimum supported version

"user-join"

(userId: string) => void;

A user joins the whiteboard or annotation.

1.0.1

"user-leave"

(userId: string) => void;

A user leaves the whiteboard or annotation.

1.0.1

"doc-load-failed"

(docId: string, docName: string) => void;

The document fails to load.

1.0.1

"doc-ready"

(docId: string) => void;

The document is loaded.

1.0.1

"doc-created"

(docId: string) => void;

Adding a document

"doc-switched"

(docId: string) => void;

The document is switched.

1.0.1

"doc-deleted"

(docId: string) => void;

The document is deleted.

1.0.1

"user-vision-share-start"

(userId: string) => void;

A user starts sharing their view.

1.0.1

"user-vision-share-stop"

(userId: string) => void;

A user stops sharing their view.

1.0.1

"vision-lock-stop"

() => void;

The local view sharing is stopped.

1.0.1

"background-image-updated"

(docId: string, pageIndex: number, imgUrl: string) => void;

The background image is updated.

1.0.1

"page-index-changed"

(activeDocId: string, pageIndex: number, totalPages: number) => void;

The page index is changed.

1.0.1

"viewport-updated"

(

scale: number,

viewport: {

minx: number;

miny: number;

maxx: number;

maxy: number;

},

) => void;

The viewport changes.

1.0.1

"viewport-updated-by-self"

() => void;

An event triggered when the viewport size changes due to the user's own operation.

1.0.1

"history-changed"

(canUndo: boolean, canRedo: boolean) => void;

Triggered when the undo or redo history changes.

1.0.1

API details

open()

Opens the whiteboard and joins the whiteboard session.

Type signature

open(wrapperEle: HTMLElement): Promise<void>;

Parameters

Parameter

Type

Description

wrapperEle

HTMLElement

The HTML element where the whiteboard is embedded.

Back

Promise<void>

leave()

Leaves the whiteboard session. Other users receive an event that the current user has left. You can use this method to leave a whiteboard session without affecting other users.

After this method is called, the current whiteboard instance is retained and can be retrieved by its ID. If you want to continue using the whiteboard, you can retrieve the whiteboard instance and call `joinSession` to rejoin the session.

Type signature

leave(): void;

Returns

void

close()

Closes the local whiteboard but does not stop the whiteboard session.

Type signature

close(): void;

Returns

void

stop()

Stops the whiteboard. Other users receive a signal that the whiteboard is stopped. You can use this method to end the whiteboard session for all users.

After this method is called, the current whiteboard instance is cleared and revoked.

Type signature

close(): void;

Returns

void

joinSession()

Rejoins the whiteboard session.

Type signature

joinSession(): void;

Returns

void

addBackgroundImages()

Imports a specified number of background images and creates a new document that uses these images as the background.

Type signature

addBackgroundImages(urls: string[], docName?: string, docId?: string): void;

Parameters

Parameter

Type

Description

urls

string[]

A list of image URLs.

docName

string

The document name.

docId

string

The document ID.

Returns

void

addImageShape()

Adds an image to the whiteboard.

Type signature

addImageShape(url: string): Promise<void>;

Parameters

Parameter

Type

Description

url

string

The background image URL.

Back

Promise<void>

addPdfDoc()

Adds a PDF document from a URL and returns the document ID.

Type signature

addPdfDoc(url: string, name: string, docId?: string, fileKey?: string): string;

Parameters

Parameter

Type

Description

url

string

The URL of the PDF document.

name

string

The name of the PDF document.

docId

string

The document ID.

fileKey

string

The file key.

Back

string

addStamp()

Adds a stamp resource.

Type signature

addStamp(stampId: string, url: string, resizable: boolean): void;

Parameters

Parameter

Type

Description

stampId

string

The stamp ID.

url

string

The URL of the stamp image.

resizable

boolean

Indicates whether the stamp has a fixed size.

Back

void

addPage()

Adds a new page to the end of the current document.

Type signature

addPage: (autoSwitch?: boolean) => any;

Parameters

Parameter

Type

Description

autoSwitch

boolean

Indicates whether to automatically switch to the new page. The default value is `true`.

Returns

any

alignVision()

Performs a one-time synchronization of the view during the session. Other clients are forced to use the specified view. This setting is effective only for the current page.

Type signature

alignVision(): void;

Returns

void

clearContents()

Clears the content drawn by all users on the canvas. Admin permission is required.

Type signature

clearContents(curPage: boolean, clearType: 'all' | 'draws' |'backgroundImage'): void;

Parameters

Parameter

Type

Description

curPage

boolean

Indicates whether to clear only the current page.

clearType

'all' | 'draws' |'backgroundImage'

Purge by content type

Returns

void

clearDocContents()

Clears the content of a document. Admin permission is required.

Type signature

clearContents(docId: string, clearType: 'all' | 'draws' |'backgroundImage'): void;

Parameters

Parameter

Type

Description

docId

string

The document ID.

clearType

'all' | 'draws' |'backgroundImage'

Purge by content type

Returns

void

clearUserContents()

Clears the content drawn by a specific user. Admin permission is required to clear content drawn by other users.

Type signature

clearUserContents(userId: string, curPage: boolean, clearType: WBClearType): void;

Parameters

Parameter

Type

Description

userId

string

User ID

curPage

boolean

Indicates whether to clear only the current page.

clearType

'all' | 'draws' |'backgroundImage'

Purge by content type

Returns

void

center()

Resets the whiteboard view to the center, which is the initial position.

Type signature

center(doc?: any): void;

Parameters

Parameter

Type

Description

doc

Doc

Specifies the document to be centered. By default, the currently used document is centered.

Back

void

createDoc()

Creates a document.

Type signature

createDoc(totalPages: number, docName: string, width?: number, height?: number, docId?: string): void;

Parameters

Parameter

Type

Description

totalPages

number

The number of pages in the document.

docName

string

The document name.

width

number

The document width.

height

number

The document height.

docId

string

The document ID.

Returns

void

deleteDoc()

Deletes a document.

Type signature

deleteDoc(docId: string, switchDocId?: string): void;

Parameters

Parameter

Type

Description

docId

string

The document ID.

switchDocId

string

The ID of the document to switch to after deletion. If this parameter is not specified and the deleted document is the current document, the view switches to the default document. If another document is deleted, the view does not switch.

Back

void

disableCursorSync()

Disables cursor position synchronization.

Type signature

disableCursorSync(): void;

Returns

void

disableWheelScale()

Disables canvas scaling using the mouse wheel.

Type signature

disableWheelScale(): void;

Returns

void

disableScaleAndMove()

Disables scaling the panel and moving the canvas with gestures.

Type signature

disableScaleAndMove(): void;

Returns

void

enableCursorSync()

Enables cursor position synchronization.

Type signature

enableCursorSync(): void;

Back

void

enableScaleAndMove()

Enables scaling the panel and moving the canvas with gestures.

Type signature

enableScaleAndMove(): void;

Returns

void

enableWheelScale()

Enables canvas scaling using the mouse wheel.

Type signature

enableWheelScale(): void;

Returns

void

enumerateDocs()

Lists information about all documents.

Type signature

enumerateDocs(): {
        docId: string;
        name: string;
        creator: string;
        currentPage: number;
        fileKey: string;
    }[];

Returns

{

docId: string;

name: string;

creator: string;

currentPage: number;

fileKey: string;

}[];

getCurrentPageNumber()

Retrieves the current page number.

Type signature

getCurrentPageNumber(): number;

Returns

number

getCursorSyncType()

Retrieves the cursor synchronization type. The cursor can be synchronized for all movements or only when drawing.

Type signature

getCursorSyncType(): "all" | "write";

Returns

"all" | "write"

getToolType()

Retrieves the current tool type.

Type signature

getToolType(): ShapeType;

Returns

ShapeType

getStatistics()

Retrieves statistics on the shapes created by users.

Type signature

getStatistics(): {
        userId: string;
        shapes: {
            shapeStyle?: ShapeStyle;
            shapeId: string;
            visible: boolean;
            type: ShapeType;
            fontStyle?: FontStyle;
            text?: string;
            creator: string;
        }[];
    }[];

Returns

{ userId: string; shapes: { shapeStyle?: ShapeStyle; shapeId: string; visible: boolean; type: ShapeType; fontStyle?: FontStyle; text?: string; creator: string; }[]; }[]

getTotalNumberOfPages()

Retrieves the total number of pages in the currently active whiteboard document.

Type signature

getTotalNumberOfPages(): number;

Returns

number

getTranslate()

Retrieves the current horizontal and vertical offset of the canvas.

Type signature

getTranslate(): {
        x: number;
        y: number;
    };

Returns

{

x: number;

y: number;

}

gotoPage()

Goes to a specified page number. The page number is 0-indexed.

Type signature

gotoPage(pageIndex: number, docId?: string, autoSwitchToDoc?: boolean): void;

Parameters

Parameter

Type

Description

pageIndex

number

The page number.

docId

string

The document ID. By default, the operation is performed on the current document.

autoSwitchToDoc

boolean

Indicates whether to automatically switch to this document. The default value is `true`.

Returns

void

insertPage()

Insert a document

Type signature

insertPage(pageIndex: number, autoSwitch?: boolean, docId?: string, autoSwitchToDoc?: boolean): any;

Parameters

Parameter

Type

Description

pageIndex

number

The page number.

autoSwitch

boolean

Indicates whether to automatically switch to the new page.

docId

string

The document ID. By default, the operation is performed on the current document.

autoSwitchToDoc

boolean

Indicates whether to automatically switch to this document. The default value is `true`.

Returns

void

nextPage()

Switches to the next page.

Type signature

nextPage(): void;

Returns

void

prevPage()

Switches to the previous page.

Type signature

prevPage(): void;

Returns

void

removePage()

Deletes a specified page.

Type signature

removePage: (index?: number, docId?: string) => void;

Parameters

Parameter

Type

Description

index

number

The page number.

docId

string

The document ID.

Returns

void

initVision()

Sets the position of the whiteboard viewport. The canvas automatically scales to an appropriate ratio to ensure that the selected viewport is centered in the current visible area. This is a global setting for the whiteboard session. After this is set, other users also follow this configuration.

After `sizeConfig` is specified, newly created blank whiteboard pages also follow this configuration. This does not apply to dynamic courseware, transcoded documents, or pages that contain background images. These layouts are scaled appropriately based on the courseware or background image.

Type signature

initVision(width: number, height: number, limited?: boolean): void;

Parameters

Parameter

Type

Description

width

number

The viewport width.

height

number

The viewport height.

limited

boolean

Indicates whether the whiteboard size is limited.

Returns

void

redo()

Redoes the last undone operation on the whiteboard.

Type signature

redo(): void;

Returns

void

undo()

Undoes the last operation on the whiteboard.

Type signature

undo(): void;

Returns

void

reset()

Clears the whiteboard state and restores it to the initial state.

Type signature

reset(): void;

Returns

void

setToolType()

Sets the tool type.

Type signature

setToolType(insertType: ShapeType): void;

Parameters

Parameter

Type

Description

insertType

ShapeType

The tool type.

Returns

void

setBackgroundImage()

Sets the background image.

Type signature

setBackgroundImage(url: string): any;

Parameters

Parameter

Type

Description

url

string

The image URL.

Back

any

setBackgroundImageScalingMode()

Sets the scaling mode for the whiteboard background image.

Type signature

setBackgroundImageScalingMode(scaleMode: ImageScalingMode): void;

Parameters

Parameter

Type

Description

scaleMode

'auto' | 'fillWidth' | 'fillHeight'

The background image scaling mode.

Returns

void

setCursorSyncType()

Sets the cursor synchronization type.

Type signature

setCursorSyncType(type: 'write' | 'all'): void;

Parameters

Parameter

Type

Description

type

'write' | 'all'

`write` (default): Synchronization occurs only when the mouse button is pressed to draw and ends when the button is released. `all`: Synchronization occurs whenever the mouse moves. The cursor position is cleared if the mouse is idle for 5 s.

Returns

void

setRoleType()

Sets the whiteboard role type.

Type signature

setRoleType(roleType: WBRoleType): void;

Parameters

Parameter

Type

Description

roleType

'Admin' | 'Attendee' | 'Viewer'

The role type.

Back

void

setScale()

Sets the scaling ratio of the current whiteboard view. The valid range is 0.1 to 5.

Note

If the whiteboard view size is limited by calling `initVision`, for example, to 1920 × 1080, and the actual rendered DOM node size is 960 × 540, the minimum scale is 0.5. The scaled view cannot be smaller than the width and height of the actual rendered DOM node.

Type signature

setScale(scale: number): void;

Parameters

Parameter

Type

Description

scale

number

The scaling ratio. The valid range is 0.1 to 5.

Returns

void

snapshot()

Takes a snapshot of the current whiteboard content.

Type signature

snapshot(autoDownload?: boolean, mode?: 'all' | 'view', format?: 'png' | 'jpeg', quality?: number): Promise<string>;

Parameters

Parameter

Type

Description

autoDownload

boolean

Indicates whether to automatically download the snapshot. The default value is `true`.

mode

'all' | 'view'

Specifies whether to capture the entire whiteboard or only the visible area. For PDF documents, only the visible area can be captured.

format

'png' | 'jpeg'

The image file format.

quality

number

The image resolution compression ratio. The default value is 0.5.

Returns

Promise<string>

setBackgroundImageScalingMode()

Sets the scaling mode for the whiteboard background image.

Type signature

setBackgroundImageScalingMode(scaleMode: ImageScalingMode): void;

Parameters

Parameter

Type

Description

scaleMode

'auto' | 'fillWidth' | 'fillHeight'

The background image scaling mode.

Returns

void

startFollowVision()

Enable Camera Follow

Type signature

startFollowVision(): void;

Returns

void

stopFollowVision()

Stops following another user's view.

Type signature

stopFollowVision(): void;

Returns

void

startVisionShare()

Starts sharing your view. Your view is synchronized with other users, and they receive an invitation to follow your view.

Other users can also start following your view while you are sharing it. If another user starts sharing their view, your view sharing is terminated.

You can listen for the `"user-vision-share-start"` event to receive view sharing requests from others.

You can listen for the `"user-vision-share-stop"` event to receive notifications when others stop sharing their view.

You can listen for the `"vision-lock-stop"` event. This event is triggered when your view sharing permission is preempted by another user while you are sharing.

Type signature

startVisionShare(): void;

Back

void

stopVisionShare()

Stops sharing your view and sends a message to clear your view resource information.

Type signature

stopVisionShare(): void;

Returns

void

switchToDoc()

Switches the active whiteboard document.

Type signature

switchToDoc(docId: string): void;

Parameters

Parameter

Type

Description

docId

string

The document ID.

Returns

void

transcodeFile()

Transcodes a file.

Type signature

transcodeFile(params: {
        targetType: 'png' | 'jpg' | 'pdf';
        onUploadProgress?: (state: {
            total: number;
            loaded: number;
        }) => void;
        onTranscodeProgress?: (status: 'init' | 'processing' | 'success' | 'failed') => void;
    }): Promise<{
        pageCount: number;
        url: string[];
        fileName: string;
        docId: string;
    }>;

Parameters

Parameter

Type

Description

param

{ targetType: 'png' | 'jpg' | 'pdf'; onUploadProgress?: (state: { total: number; loaded: number; }) => void; onTranscodeProgress?: (status: 'init' | 'processing' | 'success' | 'failed') => void; }

Transcoding configuration parameters:

targetType: The target file type.

onUploadProgress: The callback for file upload progress.

onTranscodeProgress: The callback for transcoding progress.

Returns

Promise<{

pageCount: number;

url: string[];

fileName: string;

docId: string;

}>

setTranslate()

Sets the canvas offset.

Type signature

setTranslate(x: number, y: number, smooth?: boolean, duration?: number): void;

Parameters

Parameter

Type

Description

x

number

The horizontal offset.

y

number

The vertical offset. If it is a PDF view, you can only move vertically.

smooth

boolean

Indicates whether to move smoothly. The default value is `false`.

duration

number

The duration of the smooth movement. The default value is 400 ms.

Returns

void

setSelectedShapeFontStyle()

Sets the font style of the currently selected shape.

Type signature

setSelectedShapeFontStyle(style: {
        italic?: boolean;
        bold?: boolean;
        fontSize?: number;
    }): void;

Parameters

Parameter

Type

Description

style

{

italic?: boolean;

bold?: boolean;

fontSize?: number;

}

italic: Specifies whether the text is in italics.

bold: Indicates whether the text is bold.

fontSize: The font size.

Returns

void

setSelectedShapeStyle()

Sets the style of the currently selected shape.

Type signature

setSelectedShapeStyle(style: {
        lineWidth?: number;
        strokeStyle?: string;
        fillStyle?: string;
        fillType?: string;
    }): void;

Parameters

Parameter

Type

Description

style

{

lineWidth?: number;

strokeStyle?: string;

fillStyle?: string;

fillType?: string;

}

fillStyle: The fill color. Only RGBA color values are supported, such as `rgba(0,0,0,0.2)`.

fillType: Specifies whether to fill the shape, such as a circle or a square. `none` indicates no fill. `color` indicates a color fill.

lineWidth: The line width.

strokeStyle: The color of the border or line segment. Only RGBA color values are supported, such as `rgba(0,0,0,0.2)`.

Returns

void

setShapesVisible()

Hides the drawn paths on the whiteboard. You can use this method to hide all paths and optionally hide the background image.

Type signature

setShapesVisible(enabled: boolean, hideBackgroundImg?: boolean): void;

Parameters

Parameter

Type

Description

enabled

boolean

Indicates whether to hide the paths.

hideBackgroundImg

boolean

Indicates whether to hide the background image. The default value is `false`.

Back

void

setStamp()

Selects a stamp to use. Before you select a stamp, you must add the corresponding stamp resource.

Type signature

setStamp(stampId: string): void;

Parameters

Parameter

Type

Description

stampId

string

The stamp ID.

Returns

void

uploadImage()

Uploads an image.

Type signature

uploadImage(setAsBackground?: boolean, onProgress?: (state: {
        total: number;
        loaded: number;
    }) => void): Promise<void>;

Parameters

Parameter

Type

Description

setAsBackground

boolean

Indicates whether to set the image as the background. The default value is `true`.

onProgress

(state: {

total: number;

loaded: number;

}) => void

The callback for image upload. It supports upload progress. The code value corresponds to the status:

* -3: upload_failed, -2: err_failed_fetch_upload_token, -1: err_file_too_large,

Returns

Promise<void>

uploadPDF()

Uploads a PDF file.

Type signature

uploadPDF(onProgress?: (state: {
        total: number;
        loaded: number;
    }) => void): Promise<{
        url: string;
        fileName: string;
        docId: string;
    }>;

Parameters

Parameter

Type

Description

onProgress

(state: {

total: number;

loaded: number;

}) => void

The callback for PDF upload. It supports upload progress. The code value corresponds to the status:

* -3: upload_failed, -2: err_failed_fetch_upload_token, -1: err_file_too_large

Back

Promise<{

url: string;

fileName: string;

docId: string;

}>

usePdf()

Using the PDF plugin

Type signature

static usePdf(plugin: PdfPlugin): void;

Parameters

Parameter

Type

Description

plugin

(state: {

total: number;

loaded: number;

}) => void

The callback for PDF upload. It supports upload progress. The code value corresponds to the status:

* -3: upload_failed, -2: err_failed_fetch_upload_token, -1: err_file_too_large

Returns

void

updateCanvasSize()

Manually updates the canvas size. You can typically call this method to update the canvas size information after the external canvas container changes.

Type signature

updateCanvasSize: (autoAdjust?: boolean, keepScale?: boolean) => void;

Parameters

Parameter

Type

Description

autoAdjust

boolean

Indicates whether to automatically adjust the canvas content. The default value is `true`.

keepScale

boolean

Indicates whether to maintain the scaling ratio when automatically adjusting the canvas content. The default value is `false`.

Returns

void

on()

Listens for a specified event and sets a callback function.

Type signature

on(event: string, fn: Function): void;

Parameters

Parameter

Type

Description

event

string

The specified event to listen for.

fn

Function

The callback function that is triggered when the event occurs.

Returns

void

off()

Removes the listener for a specified event.

Type signature

off(event: string, fn: Function): void;

Parameters

Parameter

Type

Description

event

string

The specified event to listen for.

fn

Function

The callback function that is triggered when the event occurs.

Returns

void

once()

Listens for a specified event once. The listener is removed after the callback function is triggered.

Type signature

once(event: string, fn: Function): void;

Parameters

Parameter

Type

Description

event

string

The specified event to listen for.

fn

Function

The callback function that is triggered when the event occurs.

Returns

void

removeAllListeners()

Removes the listeners for a specified event or all events on this object.

Type signature

removeAllListeners(event?: string): void;

Parameters

Parameter

Type

Description

event

string

(Optional) If a specific event is set, the corresponding listener callback functions are cleared. If this parameter is not specified, the listener functions for all events of the object are cleared.

Returns

void

Event details

"user-join"

The user joined the whiteboard.

Type signature

'user-join': (uid: string) => void;

Example

RtcWhiteboard.on('user-join', (uid) => {
 console.log(uid);
});

"user-leave"

The user has left the whiteboard.

Type signature

'user-leave': (uid: string) => void;

Example

RtcWhiteboard.on('user-leave', (uid) => {
 console.log(uid);
});

"doc-load-failed"

The document failed to load.

Type signature

'doc-load-failed': (docId: string, docName: string) => void;

Example

RtcWhiteboard.on('doc-load-failed', (docId, docName) => {
 console.log(docId, docName);
});

"doc-ready"

The document loaded successfully.

Type signature

'doc-ready': (docId: string) => void;

Example

RtcWhiteboard.on('doc-ready', (docId) => {
 console.log(docId);
});

"user-vision-share-start"

User view sharing has started.

Type signature

'user-vision-share-start': (userId: string) => void;

Example

RtcWhiteboard.on('user-vision-share-start', (userId) => {
 console.log(userId);
});

"vision-lock-stop"

Local view sharing has stopped.

Type signature

'vision-lock-stop': () => void;

Example

RtcWhiteboard.on('vision-lock-stop', () => {
});

"user-vision-share-stop"

The user view is no longer shared.

Type signature

'user-vision-share-stop': (userId: string) => void;

Example

RtcWhiteboard.on('user-vision-share-stop', (userId) => {
 console.log(userId);
});

"user-vision-share-stop"

The user's view is no longer being shared.

Type signature

'user-vision-share-stop': (userId: string) => void;

Example

RtcWhiteboard.on('user-vision-share-stop', (userId) => {
 console.log(userId);
});

"viewport-updated"

Viewing window changes

Type signature

'viewport-updated': (
    scale: number,
    viewport: {
      minx: number;
      miny: number;
      maxx: number;
      maxy: number;
    },
  ) => void;

Example

RtcWhiteboard.on('viewport-updated', (scale, viewport) => {
 console.log(scale, viewport);
});

"doc-switched"

The document has been switched.

Type signature

'doc-switched': (docId: string) => void;

Example

RtcWhiteboard.on('doc-switched', (docId) => {
 console.log(docId);
});

"doc-created"

Add a document

Type signature

'doc-created': (docId: string) => void;

Example

RtcWhiteboard.on('doc-created', (docId) => {
 console.log(docId);
});

"doc-deleted"

The document has been deleted.

Type signature

'doc-deleted': (userId: string) => void;

Example

RtcWhiteboard.on('doc-deleted', (userId) => {
 console.log(userId);
});

"background-image-updated"

Updating the background image

Type signature

  'background-image-updated': (docId: string, pageIndex: number, imgUrl: string) => void;

Example

RtcWhiteboard.on('background-image-updated', (docId) => {
 console.log(docId);
});

"page-index-changed"

Changes to document page numbers

Type signature

'page-index-changed': (activeDocId: string, pageIndex: number, totalPages: number) => void;

Example

RtcWhiteboard.on('page-index-changed', (docId) => {
 console.log(docId);
});

"viewport-updated-by-self"

Viewing window changes

Type signature

'viewport-updated-by-self': () => void;

Example

RtcWhiteboard.on('viewport-updated-by-self', () => {
});

"history-changed"

Triggered when the undo or redo history changes.

Type signature

'history-changed': (canUndo: boolean, canRedo: boolean) => void;

Example

RtcWhiteboard.on('history-changed', (canUndo, canRedo) => {
 console.log(canUndo, canRedo);
});