Javascript: ImageCollection.addInline Method
Description
Creates and inserts a new image inline, which means that it is treated in the text like a single character. The image is inserted at the specified text input position.
Syntax
<void> ImageCollection.addInline(<string> imageData, <number> textPosition, [<RequestImageCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| imageData | The base64 encoded image data. |
| textPosition | Specifies the text position at which the barcode is to be inserted. If -1 is specified, the barcode is inserted at the current input position. |
| callback | Optional. The newly created image object is returned via this callback function. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example inserts a self-contained one-pixel PNG at the input position and gives it an accessible name.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
const pixelPng = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";
TXTextControl.images.addInline(pixelPng, -1, function(image) {
image.setName("Status indicator", function() {
console.log("Inline image inserted and named.");
}, onTxError);
}, onTxError);