# Javascript: BarcodeCollection.addAnchoredAtLocation Method

> Inserts a new barcode which is anchored to the specified text position. It has the specified location relative to the paragraph it is anchored to and a textflow which is given through the insertionMode parameter. Anchored barcode are moved with the text.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: BarcodeCollection.addAnchoredAtLocation Method
- **717 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/barcodecollection/addanchoredatlocation-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/barcodecollection/addanchoredatlocation-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/barcodecollection/addanchoredatlocation-method/llms-full.txt

---

### Description

Inserts a new barcode which is anchored to the specified text position. It has the specified location relative to the paragraph it is anchored to and a textflow which is given through the insertionMode parameter. Anchored barcode are moved with the text.

### Syntax

```javascript
<void> BarcodeCollection.addAnchoredAtLocation(<RequestBarcodeFrameCallback> callback, [<ErrorCallback> errorCallback], <BarcodeType> barcodeType, <string> text, <Point> location, <number> textPosition, <FrameInsertionMode> insertionMode)
```

### Parameters

| Parameter | Description |
|---|---|
| callback | The newly created barcode object is returned via this callback function. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| barcodeType | The barcode type. |
| text | The text the barcode should encrypt. |
| location | Specifies the location, in twips, at which the barcode is to be inserted. This is a location relative to the top left corner either of a page or of a paragraph. |
| 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. |
| insertionMode | Specifies how the text flow is handled. |

### Examples

The following example demonstrates `BarcodeCollection.addAnchoredAtLocation` in a practical document-editing workflow. It inserts a new barcode which is anchored to the specified text position. It has the specified location relative to the paragraph it is anchored to and a textflow which is given through the insertionMode parameter. Anchored barcode are moved with the text.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function addAnchoredAtLocation(barcodeType) {
    TXTextControl.barcodes.addAnchoredAtLocation(
        function(barcodeFrame) {
            if (!barcodeFrame) {
                console.warn("No barcode frame was returned.");
                return;
            }
            
            console.log("add anchored at location result:", barcodeFrame);
        },
        onTxError,
        barcodeType,
        "Quarterly report",
        { x: 1440, y: 720 },
        -1,
        TXTextControl.FrameInsertionMode.AsCharacter
    );
}
```

---

## Nearby

- **Previous:** [Javascript: BarcodeCollection.addAnchored Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/barcodecollection/addanchored-method/llms-full.txt)
- **Next:** [Javascript: BarcodeCollection.addAtFixedPositionInDocument Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/barcodecollection/addatfixedpositionindocument-method/llms-full.txt)
