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 and end
// index: The start and end index of the text to be replaced
// lineIndex: The start and end line index of the text to be replaced
// You can get the index of which line by splitting the text \r\n, and you can wrap the text with \n when inserting text
const start = {
index: 3,
lineIndex: 0
}
const end = {
index: 6,
lineIndex: 0
}
await box.replaceTextWithIndex('Test', start, end)
// 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()