Skip to content

Get or Set Content Box

You can get or set content box with these API below.

Get the list of content boxes

javascript
const contentBoxesList = docViewer.getContentEditManager().getContentBoxesList()

Then You can get or set the properties or content of the content box

javascript
const box = contentBoxesList[0]
// Get the rect of the box
const rect = box.getRect

// Get the content of the box
const text = await box.getTextContents()

// Insert text with index
await box.insertTextWithIndex('Test', index)

// Replace text with start index and end index
await box.replaceTextWithIndex('Test', startIndex, endIndex)

// Replace all text of the box
await box.replaceAll('Test')

// Add text at end of the box
await box.setContent('Test')

// Replace with new image
await box.replaceImage(imageBase64, width, height)

// Get the base64 data of the image
await box.getImageData()